Automation Testing Interview Questions for 3 Years Experience
40 questions with answers for candidates with 3 years of experience — 3 easy, 35 medium, 2 hard.
What interviewers expect: 3 years experience
With three years, interviewers expect ownership of modules and parts of the framework. You should explain design choices, thread-safe drivers, data management, CI pipelines and API plus UI strategy. Scenario questions on flaky suites, environment issues and test selection become common, along with medium Java coding problems.
This set is weighted towards Page Object Model (7), Git, Maven and Jenkins (6), Appium Mobile Automation (5), API Testing and CI/CD (5).
Framework design decisions ThreadLocal and parallel execution CI/CD pipelines Scenario-based problem solving
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.
✓ 3 questions free • Unlock the rest in seconds
01
How do you capture a screen recording of a mobile test and attach it on failure?
// Start before the test, stop and save only if it fails
driver.startRecordingScreen();
// ... test steps ...
String base64 = driver.stopRecordingScreen();
if (result.getStatus() == ITestResult.FAILURE) {
byte[] video = Base64.getDecoder().decode(base64);
Files.write(Paths.get("target/videos/" + result.getName() + ".mp4"), video);
}
02
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.
03
Why is XPath slow in Appium and what should you use instead?
For every XPath query Appium must fetch the full page source of the app, convert it into an XML document and then evaluate the expression, which can take seconds on large screens and is even slower on iOS. Index-based XPath also breaks when layouts change. Use accessibility id first, then resource-id, Android UiAutomator selectors or iOS predicate strings and class chains, which are evaluated natively on the device and are much faster.
04
How do you handle a component that appears inside many different pages, like a modal dialog?
Create a ModalComponent class scoped to the modal root element, with methods like title(), confirm() and cancel(). Pages that open modals return the component, such as cartPage.removeItem() returning ConfirmModal. The component waits for itself to appear and disappear. This keeps modal logic in one place and avoids copying locators into every page.
Fluent page objects return objects from every action so a test reads like a sentence, for example new SearchPage(driver).searchFor("phone").filterByBrand("X").sortByPrice().firstResult(). It improves readability and models navigation. The risk is long chains that hide failures, so keep chains to a single journey and use clear method names that show which page you end on.
07
Tell me about a time you moved from web automation to mobile automation.
Situation: my team needed Android regression tests and I only knew Selenium. Task: deliver a smoke suite in one month. Action: I learned Appium 2 setup, used Appium Inspector to find locators, asked developers to add accessibility ids, and reused our TestNG, POM and reporting structure with a new driver factory. Result: twenty smoke tests ran nightly on emulators within four weeks, and release smoke testing dropped from half a day to forty minutes.
08
How do you share state between step definition classes in Cucumber Java?
Use dependency injection. With cucumber-picocontainer (or Spring/Guice), create a context class such as TestContext holding the driver, page objects and scenario data, and add it as a constructor parameter in every step class. Cucumber creates one instance per scenario and injects the same object everywhere, so state is shared within a scenario but never leaks between scenarios. Avoid static fields because they break parallel runs.
09
How do you run Selenium tests in Docker containers in CI?
Use official Selenium images, either standalone-chrome for simple runs or a Grid with hub and node containers via Docker Compose. The test container or Jenkins agent points RemoteWebDriver to http://selenium-hub:4444. Containers give the same browser version everywhere and are cleaned after each run. Add shm_size for Chrome stability and record videos for failed tests if needed.
For Allure, install the Allure Jenkins plugin, configure the commandline tool, and add allure results: [[path: 'target/allure-results']] in the post always block. For Extent, archive the HTML file and use the HTML Publisher plugin to show it as a build link. Keep report history per build and share the link in failure notifications.
An authorisation framework where a client obtains an access token from an auth server and sends it as a Bearer token; tests fetch and reuse the token in setup.
13
What is the Maven Failsafe plugin and how is it different from Surefire?
Surefire runs unit tests in the test phase and stops the build as soon as tests fail. Failsafe runs integration tests in the integration-test phase and checks results later in the verify phase, so post-integration-test steps, like stopping a server or Docker containers, still run after failures. By default Failsafe picks classes named *IT. Many teams run UI and API suites through Failsafe with mvn verify for that reason.
A special method that initialises an object. It can be overloaded with different parameters, and testers use it to pass the WebDriver into page classes.
15
Write a simple page object class for a login page.
public class LoginPage {
private final WebDriver driver;
private final By user = By.id("username");
private final By pass = By.id("password");
private final By submit = By.cssSelector("button[type='submit']");
public LoginPage(WebDriver driver) { this.driver = driver; }
public HomePage loginAs(String u, String p) {
driver.findElement(user).sendKeys(u);
driver.findElement(pass).sendKeys(p);
driver.findElement(submit).click();
return new HomePage(driver);
}
}
16
How do you manage test environments for a CI pipeline?
Keep environment details in config files or environment variables per env, never in code. Prefer ephemeral environments created per pull request with containers, seeded with known data and destroyed afterwards. For shared environments, reserve them through the pipeline, reset data before runs and monitor health with a pre-test check so tests do not fail due to a down service.
17
How do you handle authentication types in REST Assured?
Basic auth uses auth().preemptive().basic(user, pass). Bearer tokens are set as a header: header("Authorization", "Bearer " + token). OAuth 2.0 can use auth().oauth2(token) after fetching the token from the token endpoint. API keys go in a header or query param. Fetch tokens once per suite or cache them with an expiry check rather than logging in before every test.
BasePage is a parent class for all page objects holding common things: the driver reference, a WebDriverWait, and helper methods such as click with wait, type, getText, waitForVisible and scrollIntoView. Child pages extend it and stay focused on page-specific locators and actions. Keep it small; if it grows into hundreds of methods, move helpers into separate utility classes using composition.
compile is the default and available everywhere. test is only for test compile and run, such as TestNG and REST Assured. provided is needed for compiling but supplied at runtime by the container. runtime is not needed to compile but needed to run, like JDBC drivers. system and import are rarer. In test projects, mark test libraries as test scope unless framework code in src/main uses them.
20
Tell me about a time you had to automate a very complex or unusual UI.
Situation: our app had a drag-and-drop dashboard builder built on canvas. Task: automate the key layout flows. Action: I tried the Actions class, found canvas elements were not in the DOM, and worked with developers to expose test hooks and an API to verify saved layouts. Result: we automated the main flows reliably, combining a few UI actions with API checks.
21
How do you build dynamic JSON request bodies without hard-coded strings?
Use POJOs with a builder pattern or Lombok @Builder, so tests write User.builder().name("Ravi").role("QA").build(). For quick cases use a HashMap or Jackson ObjectNode. For large templates, keep a JSON file and change fields with a JSON library. Combine with a faker library for unique values. This avoids escaping issues and makes changes to the schema easy to update.
No. Cucumber adds a translation layer, so it is worth it for business-facing acceptance tests that stakeholders discuss. Unit tests, low-level API checks, data validations and technical edge cases are faster to write and maintain directly in TestNG or JUnit. A healthy project uses Cucumber for a focused set of key behaviours and plain code tests for everything else.
25
What branching strategy do you use for test automation code?
Most teams use trunk-based development or a light GitHub Flow: short-lived feature branches from main, a pull request with review and a CI run, then merge. Long-lived branches cause painful conflicts. Keep automation code in the same repository as the app when possible so tests change together with features, or tag test versions to match app releases.
26
How do you avoid page object classes becoming too large?
Split pages into components for repeated or complex areas, keep only user actions as public methods, move generic helpers to BasePage or utilities, and avoid one method per element. If a page has distinct modes like view and edit, use separate classes. Review page classes during code review and refactor when they cross a few hundred lines.
27
What are the UiAutomator2 and XCUITest drivers in Appium?
They are the platform drivers that actually control the device. UiAutomator2 drives Android by installing a small server app on the device that uses Google's UiAutomator framework. XCUITest drives iOS through Apple's XCTest framework via WebDriverAgent, which needs Xcode and signing for real devices. In Appium 2 they are installed separately with appium driver install, so each project picks only the drivers and versions it needs.
28
How do you undo a commit that has already been pushed?
Use git revert <commit>, which creates a new commit that reverses the changes and keeps history intact, safe for shared branches. git reset moves the branch pointer backwards and is fine for local commits, but resetting and force-pushing a shared branch rewrites history and breaks teammates' clones. If force push is truly needed, use --force-with-lease and tell the team.
29
A login action can lead either to the dashboard or to an error message. How should the page object method return?
Make the outcome explicit with separate methods instead of one method guessing. For example loginAs(user) returns DashboardPage for valid credentials, while loginExpectingError(user) returns the same LoginPage so the test can check the error. Each method waits for its expected page and fails clearly if it does not appear. This keeps tests readable and avoids returning a generic Object or checking types in tests.
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.
31
A click works locally but throws ElementClickInterceptedException in CI. How do you fix it?
Another element, such as a cookie banner, loader overlay or sticky header, covers the target. In CI the window is often smaller, so the layout differs. Set a fixed window size, wait for the overlay to disappear with invisibilityOfElementLocated, close banners in setup and scroll the element into view. Use a JavaScript click only as a last resort, since it bypasses real user behaviour.
32
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.
33
Tell me about a time a flaky test cost your team time and how you fixed it permanently.
Situation: a checkout test failed about one run in five and the team started ignoring red builds. Task: fix the root cause, not just rerun it. Action: I added logs and screenshots, found it raced with an async price recalculation, replaced a fixed sleep with a wait on the updated total and asked developers for a loading flag. Result: zero failures in the next sixty runs, and the team trusted red builds again.
34
What are page components or page fragments in POM?
Components are classes for UI parts that repeat across pages, such as the header, search bar, date picker or a data table. A page object then has-a component: homePage.header().search("laptop"). This follows composition over inheritance, avoids duplicate locators and matches modern component-based frontends. Components are usually scoped to a root WebElement so locators search only inside that element.
35
How do you mock an external API in automation tests?
Use a tool such as WireMock or MockServer to run a stub server that returns predefined responses for given requests. Point the application or tests to the stub with configuration. This lets you test error codes, timeouts and edge cases that are hard to trigger on the real service, and keeps tests stable when the third party is down. Still keep a few tests against the real integration.
36
Tell me about a time you found a critical bug through automation.
Situation: during a sprint, my nightly regression showed checkout failing only for one payment option. Task: confirm if it was a test issue or a real bug. Action: I reproduced it manually, checked the API response and found a wrong tax value, then logged a clear defect with steps, logs and screenshots. Result: developers fixed it before the release and the test was added to the smoke suite.
37
What is the difference between noReset and fullReset in Appium?
By default Appium clears app data between sessions but keeps the app installed. noReset set to true keeps app data and login state, which speeds up tests but can leak state between them. fullReset set to true uninstalls and reinstalls the app, giving the cleanest state but adding time. A common approach is noReset for fast suites with explicit cleanup in the test, and fullReset only for first-launch or onboarding scenarios.
git fetch downloads new commits and branches from the remote but does not change your working files; you can inspect them with git log origin/main. git pull is fetch followed by merge (or rebase if configured) into your current branch. Fetch is safer when you want to review changes before integrating them.
switchTo().frame(index, name or element) enters the frame, and switchTo().defaultContent() returns to the main page.
Frequently asked questions
What is asked in Automation Testing interviews for 3 years of experience?
With three years, interviewers expect ownership of modules and parts of the framework. You should explain design choices, thread-safe drivers, data management, CI pipelines and API plus UI strategy. Scenario questions on flaky suites, environment issues and test selection become common, along with medium Java coding problems.
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 3 years of experience?
Focus first on Framework design decisions, ThreadLocal and parallel execution, CI/CD pipelines, Scenario-based problem solving.