Automation Testing Interview Questions for Freshers
40 questions with answers for candidates with Freshers — 25 easy, 15 medium.
What interviewers expect: freshers
Freshers are expected to know core Java basics, Selenium fundamentals like locators, waits and common exceptions, basic TestNG annotations and manual testing concepts. Interviewers look for clear fundamentals, a small hands-on project and the ability to write simple Java programs. Honest answers and eagerness to learn matter more than knowing every tool.
This set is weighted towards Core Java for Testers (9), REST Assured (6), Selenium WebDriver (5), Page Object Model (4).
Core Java and OOP Locators and waits TestNG annotations A personal automation project on GitHub
Solved at this levelStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
Method chaining means page methods return a page object, either this or the next page, so calls can be linked: loginPage.enterUser("asha").enterPassword("x").submit().openOrders(). Returning the next page models navigation and makes tests read like a user journey. Be careful when an action can lead to different pages; return the correct type or provide separate methods for success and failure.
02
Your price comparison test fails because 19.99 + 0.01 is not equal to 20.0. Why?
double uses binary floating point, which cannot represent many decimal values exactly, so small rounding errors appear. For money, use BigDecimal created from strings and compare with compareTo(), or compare doubles with a tolerance such as Assert.assertEquals(actual, expected, 0.001). Also strip currency symbols and commas before parsing UI text.
A good scenario describes one behaviour in business language, uses declarative steps ("When the user logs in as a manager") rather than UI clicks ("When I click the login button"), has one When and a clear Then, stays under about 5 to 7 steps and is independent of other scenarios. The title should state the rule being checked so failures are understood without opening the code.
04
How do you test a responsive page in a mobile viewport using Selenium?
For layout checks you can set the window size, like driver.manage().window().setSize(new Dimension(390, 844)). For closer emulation in Chrome use mobile emulation in ChromeOptions: options.setExperimentalOption("mobileEmulation", Map.of("deviceName", "Pixel 7")), which also sets the user agent, pixel ratio and touch events. This catches responsive layout bugs quickly, but it is not a replacement for testing on real mobile browsers.
05
What is the difference between a page object and a utility class in a test framework?
A page object models one screen or component: its locators and the user actions possible there, such as LoginPage.loginAs. A utility class holds generic helpers not tied to any page, such as reading config, generating test data, date formatting or taking screenshots. Mixing them makes page objects bloated and utilities dependent on the UI. Keep page objects in a pages package and helpers in a utils package.
Swallowing exceptions hides failures, so TestNG never sees an error and marks the test passed. Catch only specific exceptions you can handle, add context and rethrow, or let them propagate. If you need logging, log and then throw. Code reviews should flag empty catch blocks and broad catch (Exception e) in test code.
08
What is RemoteWebDriver and how is it different from ChromeDriver?
ChromeDriver starts and controls a browser on the same machine as the test. RemoteWebDriver sends the same WebDriver commands over HTTP to a remote endpoint, such as a Selenium Grid, a Docker container or a cloud provider, which starts the browser elsewhere. You pass the Grid URL and browser options, and the rest of the test code stays the same. ChromeDriver itself actually extends RemoteWebDriver.
09
What is the difference between a Docker image and a container?
An image is a read-only template that contains an operating system layer, software and configuration, for example selenium/standalone-chrome with Chrome and ChromeDriver installed. A container is a running instance of an image with its own process, network and writable layer. You can start many containers from one image and destroy them after a test run. This is why every run starts from the same clean browser environment.
Average is the sum divided by count, so a few very slow requests can distort it. Median is the middle value, meaning half the requests were faster. The 95th percentile means 95 percent of requests were faster than that value, which reflects what most users experience including slow cases. SLAs are usually written on 90th, 95th or 99th percentiles because averages hide long tails that frustrate real users.
12
A runtime permission pop-up appears on first launch and breaks your Android tests. How do you handle it?
The cleanest fix is the capability appium:autoGrantPermissions set to true, which grants all permissions the app declares at install time. If you need to test the permission flow itself, handle the dialog explicitly by waiting for the Allow button using its resource-id and clicking it. Another option is granting a specific permission with adb shell pm grant before the test. Avoid blind try-catch around taps, because it hides real failures.
13
What is serialization and deserialization in REST Assured?
Serialization converts a Java object (POJO) into JSON for the request body; deserialization converts the response JSON back into a Java object. REST Assured does this automatically when Jackson or Gson is on the classpath: body(userPojo) serializes and response.as(User.class) deserializes. Using POJOs gives type safety, IDE support and cleaner assertions compared with hand-written JSON strings.
14
Describe a time you received critical feedback on your test code.
Situation: in my first code review, a senior said my tests were hard to read and used Thread.sleep everywhere. Task: improve without getting defensive. Action: I asked for examples, replaced sleeps with explicit waits, extracted helpers and followed the team's naming conventions. Result: my next pull requests were approved faster, and I later used the same checklist to review a junior's code.
15
Write an XPath for a button with the text "Login".
Docker Compose lets you define several containers, their images, ports, environment variables and networks in one docker-compose.yml file and start them together with docker compose up. For Selenium it means a hub plus Chrome, Firefox and Edge nodes, and even the application under test, start with one command on any laptop or CI agent. The file is version-controlled, so every tester and pipeline uses the same Grid setup.
17
Write a REST Assured test for a DELETE request followed by a check that the resource is gone.
The default lifecycle has phases in order: validate, compile, test, package, verify, install and deploy. Running a phase runs all earlier phases too, so mvn test compiles and then runs unit tests through Surefire. mvn verify also runs integration tests with Failsafe. There are also clean and site lifecycles. Automation suites usually run with mvn clean test or mvn clean verify.
Common triggers are webhooks from GitHub, GitLab or Bitbucket on push or pull request, cron schedules with triggers { cron('H 2 * * *') } for nightly regression, polling SCM (less efficient), and upstream jobs completing, such as running tests after a deploy job. Multibranch pipelines automatically create jobs for each branch and pull request containing a Jenkinsfile.
Write a utility that reads the sheet with Apache POI and returns Object[][] with one row per test case. Create a @DataProvider method that calls the utility, and set dataProvider = "loginData" on the test. Each row runs as a separate test with its own result. Keep the file in src/test/resources and consider CSV or JSON, which are easier to review in Git.
23
Tell me about a time you had to learn Java quickly for an automation role.
Situation: I moved from manual testing into an automation team using Java. Task: become productive within a month. Action: I practised core Java daily, focusing on OOP, collections and exceptions, solved small coding problems, and read the existing framework code with a senior's help. Result: in four weeks I was writing page objects and tests that passed review, and I kept learning streams afterwards.
24
Write Selenium code to wait for a loader to disappear and then click a button.
Use both, for different purposes. Emulators and simulators are cheap, fast to reset and easy to run in CI, so they suit smoke and regression runs on every commit. Real devices reveal issues emulators hide: performance on low-end hardware, camera, biometrics, push notifications, network changes and vendor-specific Android skins. A common plan is emulators in the pull request pipeline and a nightly run on a small matrix of real devices covering the most-used models.
Generally no. Page objects should expose state and actions, such as getErrorMessage() or isLoggedIn(), and tests should make the assertions. This keeps page classes reusable across positive and negative tests and keeps the test intent visible. A small exception is a simple check that the correct page has loaded, often done in the constructor or an isAt() method.
28
Write a REST Assured PUT test that updates a resource using a POJO.
Use then().time(lessThan(2000L)) for a quick check or response.getTimeIn(TimeUnit.MILLISECONDS) to log the value. This measures client-side time, including network, so set generous thresholds and treat it as a smoke signal, not a performance test. For real load and latency percentiles, use tools such as JMeter, Gatling or k6.
30
What locator strategy do you follow inside page objects?
Prefer stable attributes in this order: dedicated test attributes like data-testid, id, name, then short CSS selectors, and XPath only when text or complex relationships are needed. Avoid absolute XPaths and index-based locators. Keep locators as private final By fields at the top of the class with clear names, so updates are quick and readable.
31
Half of your TestNG tests are skipped in CI with no failure shown. What could cause it?
Usually a configuration method failed, such as @BeforeClass or @BeforeSuite throwing an exception, which makes TestNG skip dependent tests. Other causes are dependsOnMethods on a failed test, a group filter excluding setup methods without alwaysRun, or a DataProvider that threw an exception. Check the configuration failures section of the report and the log for the first exception.
32
Tell me about a time you had to explain a technical test failure to a non-technical manager.
Situation: a release was blocked by failing tests and the manager wanted to know if it was safe to ship. Task: explain the risk without jargon. Action: I separated the failures into one real bug, where customers could be charged twice, and three environment issues. I showed the bug with a short screen recording. Result: the manager delayed the release by one day, the bug was fixed and the environment issues were assigned to DevOps.
Runtime events that disrupt flow. Use try-catch-finally, throw, throws, and custom exceptions; checked exceptions must be handled while unchecked ones need not be.
34
What are pre-processors and post-processors in JMeter?
Pre-processors run before a sampler, for example a JSR223 PreProcessor that builds a signature or timestamp, or User Parameters that set values per thread. Post-processors run after a sampler and usually extract data from the response, such as JSON Extractor, Regular Expression Extractor or Boundary Extractor, storing it as a variable for later requests. Their scope depends on where they sit in the tree, so place them as children of the right sampler.
35
How do you extract a value from one response and use it in the next request?
Add the json-schema-validator dependency, place the schema file in src/test/resources, and assert with then().body(matchesJsonSchemaInClasspath("user-schema.json")). Schema validation checks field types, required fields and structure, so it catches contract changes that value checks might miss. It complements, not replaces, assertions on business values like status or totals.
38
Cucumber says a step is undefined even though the step definition exists. How do you fix it?
Check the glue path in the runner points to the package containing the step classes. Check the step text matches exactly, including quotes and parameter types, since {string} expects quoted text. Confirm the step class is under src/test/java and compiled, the annotation import is io.cucumber.java.en, and the Cucumber versions of core, java and the runner module match. Running with dryRun shows all unmatched steps quickly.
Git marks conflicting sections with <<<<<<<, ======= and >>>>>>>. Open each file, decide which change to keep or combine both, remove the markers, then git add the files and complete with git commit (or git rebase --continue). Run the affected tests before pushing. Pull often and keep branches short-lived to reduce conflicts.
40
What are stubs, mocks, fakes and spies in testing?
They are test doubles that replace real dependencies. A stub returns fixed answers, such as a fake API returning a canned user. A mock also verifies how it was called, like checking a payment service received one charge. A fake is a lightweight working version, such as an in-memory database. A spy wraps a real object and records calls. Automation testers often use WireMock stubs to isolate tests from unstable services.
Frequently asked questions
What is asked in Automation Testing interviews for Freshers?
Freshers are expected to know core Java basics, Selenium fundamentals like locators, waits and common exceptions, basic TestNG annotations and manual testing concepts. Interviewers look for clear fundamentals, a small hands-on project and the ability to write simple Java programs. Honest answers and eagerness to learn matter more than knowing every tool.
How many questions should I practise before a Automation Testing interview?
Work through all 40 questions here, then the company-wise sets for the employers you are targeting. Quality matters more than count: be able to explain why each answer is right.
Which topics matter most for Freshers?
Focus first on Core Java and OOP, Locators and waits, TestNG annotations, A personal automation project on GitHub.