Skip to content

Automation Testing Interview Questions for 2 Years Experience

40 questions with answers for candidates with 2 years of experience — 7 easy, 32 medium, 1 hard.

What interviewers expect: 2 years experience

At two years, you should contribute to the framework, not only write tests. Expect questions on Page Object Model, DataProvider, listeners, screenshots on failure, parallel runs and Jenkins jobs. Interviewers check that you can debug flaky tests and write REST Assured tests independently, with clean, reusable Java code.

This set is weighted towards Selenium WebDriver (8), Appium Mobile Automation (6), Git, Maven and Jenkins (4), Page Object Model (3).

Page Object Model design Listeners and reporting REST Assured tests Debugging flaky tests
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 handle a component that appears inside many different pages, like a modal dialog?

Save to ▾
Show answer
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.
02

Where do you use OOP concepts in your framework?

Save to ▾
Show answer
Encapsulation: private locators with public page methods. Inheritance: pages extend a BasePage. Polymorphism: the WebDriver interface for different browsers. Abstraction: utility layers hiding Selenium details.
03

How do you manage test data in a framework?

Save to ▾
Show answer
Use external files or APIs and database setup scripts, generate unique data per run, and clean up afterwards so tests stay independent.
04

How do you watch a test running inside a Docker Selenium container?

Save to ▾
Show answer
The selenium node and standalone images include a VNC server and noVNC. Expose port 7900 and open http://localhost:7900 in a browser; the default password is secret, or set SE_VNC_NO_PASSWORD to skip it. You can also open the Grid UI on port 4444 and click the session's video icon. This is very useful for debugging tests that fail only inside the container, such as layout or focus problems.
05

What is the New Session Queue in Selenium Grid 4 and what happens when all slots are busy?

Save to ▾
Show answer
When a test requests a session and no node slot matches, the request waits in the New Session Queue instead of failing immediately. The distributor picks it up when a matching slot frees. If it waits longer than the session request timeout, which is 300 seconds by default, the client gets a SessionNotCreatedException. Tuning this timeout and matching thread count to slot count prevents long waits and timeouts in CI.
06

Tell me about a time you reduced the run time of a test suite significantly.

Save to ▾
Show answer
Situation: our TestNG regression took three hours, so it only ran nightly. Task: get it under forty minutes to run on every merge. Action: I profiled slow tests, replaced UI login with an API token, made the driver ThreadLocal and enabled parallel classes, moved data setup to APIs and removed duplicate tests. Result: the suite ran in thirty-five minutes on four threads, and defects were caught on the same day they were introduced.
07

What is the difference between native, hybrid and mobile web apps from a testing point of view?

Save to ▾
Show answer
A native app is built with platform SDKs and is tested through native locators like accessibility id or resource-id. A mobile web app runs in the device browser, so you automate it much like desktop Selenium with mobile Chrome or Safari. A hybrid app wraps web content inside a native shell, so tests switch between the NATIVE_APP context and a WEBVIEW context. Knowing the type decides your driver, locators and setup.
08

What changed in Appium 2 compared with Appium 1?

Save to ▾
Show answer
Appium 2 split the monolithic server into a core plus separately installed drivers and plugins, managed with appium driver install and appium plugin install. It dropped the old JSON Wire Protocol in favour of W3C WebDriver only, so vendor capabilities need the appium: prefix. The default base path changed from /wd/hub to /. Old TouchAction and MultiTouchAction were removed from the Java client, so gestures use W3C Actions or mobile: commands.
09

What is REST Assured?

Save to ▾
Show answer
A Java library that makes API tests readable using given-when-then, with easy request building, response validation and JSON path support.
10

What do number of threads, ramp-up period and loop count mean in a JMeter Thread Group?

Save to ▾
Show answer
Number of threads is how many virtual users run in parallel. Ramp-up period is the time JMeter takes to start all of them, so 100 threads with a 50-second ramp-up starts two users per second. Loop count is how many times each user repeats the samplers, or you can set a duration instead. A gradual ramp-up avoids an unrealistic burst at the start and shows where response times begin to degrade.
11

Write a BasePage helper that clicks an element after waiting for it to be clickable.

Save to ▾
Show answer
public abstract class BasePage { protected final WebDriver driver; protected final WebDriverWait wait; protected BasePage(WebDriver driver) { this.driver = driver; this.wait = new WebDriverWait(driver, Duration.ofSeconds(10)); } protected void click(By locator) { wait.until(ExpectedConditions.elementToBeClickable(locator)).click(); } }
12

How do you publish Allure or Extent reports from Jenkins?

Save to ▾
Show answer
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.
13

A click works locally but throws ElementClickInterceptedException in CI. How do you fix it?

Save to ▾
Show answer
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.
14

How did you handle it when your test estimates turned out to be wrong in a sprint?

Save to ▾
Show answer
Situation: I estimated three days to automate a new module, but the UI had complex dynamic tables. Task: still deliver what the sprint needed. Action: I told the lead early on day two, proposed automating the API checks first and the UI flows next sprint, and documented the extra effort. Result: the sprint goal was met, and I now spike unfamiliar screens before estimating.
15

What does SE_NODE_MAX_SESSIONS control in the Docker Selenium images?

Save to ▾
Show answer
It sets how many browser sessions a node container can run at once. The default is one, which gives the best isolation and stability. Increasing it lets one container run several browsers in parallel, but you must also set SE_NODE_OVERRIDE_MAX_SESSIONS to true and give the container enough CPU, memory and shared memory. Many teams keep one session per container and scale the number of containers instead.
16

Your Selenium tests in CI produce blank screenshots in headless mode. What could be wrong?

Save to ▾
Show answer
The screenshot may be taken before the page renders, the window size in headless mode may be tiny, or the browser is crashing due to low shared memory in Docker. Set --window-size=1920,1080, use the new headless mode, wait for page content before capturing, and add --disable-dev-shm-usage or a larger shm size for containers.
17

A test reading a properties file works in the IDE but fails in Jenkins with FileNotFoundException. Why?

Save to ▾
Show answer
The file path is probably hard-coded or relative to the IDE working directory, or uses Windows backslashes while Jenkins runs on Linux. Load the file from the classpath with getClass().getClassLoader().getResourceAsStream("config.properties") and keep it in src/test/resources, or build paths with Paths.get. Also check the file is committed to Git and not ignored.
18

Your recorded JMeter script fails with 403 on every request after login. What is the likely cause?

Save to ▾
Show answer
The script is probably replaying hard-coded dynamic values, such as a CSRF token, session cookie or auth header captured during recording. The server rejects them because they belong to the old session. Add an HTTP Cookie Manager so cookies are handled per thread, extract the CSRF or bearer token from the login response with an extractor, and replace the recorded value with the variable. Verify with View Results Tree on one thread.
19

How do you integrate Selenium tests with Jenkins?

Save to ▾
Show answer
Create a job or pipeline that checks out code, runs mvn test, publishes reports and triggers on commits or schedules.
20

Selenium's driver version suddenly mismatches the browser version on agents. How do you prevent this?

Save to ▾
Show answer
Use Selenium Manager, built into Selenium 4.6 and later, which resolves the right driver automatically, so you do not commit driver binaries. In CI, pin browser versions using Docker images or browser options so all agents match. Avoid auto-updating browsers on test agents. Log the browser and driver versions at the start of each run to diagnose quickly.
21

What are pre-processors and post-processors in JMeter?

Save to ▾
Show answer
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.
22

Which locator strategies does Appium support and which should you prefer?

Save to ▾
Show answer
Appium supports accessibility id, id (resource-id on Android), class name, XPath, Android UiAutomator selectors, iOS predicate strings and iOS class chains. Prefer accessibility id because it is fast, works across Android and iOS and also improves app accessibility. Next use resource-id or iOS predicates. Use XPath only as a last resort because it walks the whole UI tree and is slow and brittle, especially on iOS.
23

How do you handle a web table in Selenium?

Save to ▾
Show answer
Locate rows and columns with XPath such as //table//tr and //td, loop through them to read or click cells, or build the XPath dynamically from the row text.
24

How do you switch between native and webview contexts in a hybrid app?

Save to ▾
Show answer
// Requires the webview to be debuggable in the app build Set<String> contexts = driver.getContextHandles(); for (String ctx : contexts) { if (ctx.startsWith("WEBVIEW")) { driver.context(ctx); break; } } driver.findElement(By.cssSelector("#email")).sendKeys("qa@test.com"); // back to native controls driver.context("NATIVE_APP");
25

A dropdown option list loads only after typing three letters. How do you automate selecting a value?

Save to ▾
Show answer
Type the text with sendKeys, wait for the suggestion list with visibilityOfAllElementsLocatedBy, then find the option whose text matches the required value and click it. Avoid selecting by index because suggestion order may change. If the list is virtualised, type more characters to narrow results. Verify the selected value in the input afterwards.
26

How do you undo a commit that has already been pushed?

Save to ▾
Show answer
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.
27

What is CI/CD and why does automation need it?

Save to ▾
Show answer
Continuous Integration builds and tests every commit, and Continuous Delivery ships automatically. Automated tests give fast feedback and gate releases.
28

How do you validate a response against a JSON schema in REST Assured?

Save to ▾
Show answer
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.
29

Tell me about a time you had to explain a technical test failure to a non-technical manager.

Save to ▾
Show answer
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.
30

How do you handle dynamic elements whose ids change?

Save to ▾
Show answer
Use CSS or XPath with contains(), starts-with() or stable attributes, relative axes, or data-test attributes agreed with developers.
31

How do you upload a file with REST Assured?

Save to ▾
Show answer
Use multipart: given().multiPart("file", new File("src/test/resources/report.pdf"), "application/pdf").formParam("type", "invoice").when().post("/upload").then().statusCode(200). REST Assured sets the multipart/form-data content type automatically. Verify both the status and the response, such as the returned file id or size, and test edge cases like empty, oversized and wrong-type files.
32

What are Cucumber hooks and how are they different from Background?

Save to ▾
Show answer
Hooks are Java methods annotated with @Before, @After, @BeforeStep and @AfterStep that run around scenarios or steps. Background is visible in the feature file and describes business preconditions; hooks are hidden technical setup such as starting the browser, cleaning data or attaching screenshots. Hooks can be ordered with the order attribute and filtered by tag expressions, for example @Before("@ui").
33

What are the UiAutomator2 and XCUITest drivers in Appium?

Save to ▾
Show answer
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.
34

How do you handle iframes?

Save to ▾
Show answer
switchTo().frame(index, name or element) enters the frame, and switchTo().defaultContent() returns to the main page.
35

What is idempotency in REST APIs and why does it matter for testing?

Save to ▾
Show answer
An idempotent operation gives the same result no matter how many times it is called. GET, PUT and DELETE should be idempotent; POST usually is not. Testers verify that repeating a PUT does not create duplicates and that a second DELETE returns a sensible status like 404 or 204. Retries in networks and CI make idempotency important to verify.
36

What is OAuth 2.0 in API testing?

Save to ▾
Show answer
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.
37

What does a good commit message look like?

Save to ▾
Show answer
A short summary line under about 60 characters in the imperative mood, like "Add retry for flaky payment test", followed by a blank line and a body explaining why the change was made if not obvious. Reference the ticket ID. Small focused commits with clear messages make reviews faster and help when using git log or git bisect to find when a test broke.
38

A mobile test fails intermittently because an animation is still running when you tap. How do you fix it?

Save to ▾
Show answer
Wait for a stable end state instead of sleeping, for example wait until the target element is visible and enabled or until a spinner disappears. On test devices and emulators you can disable animations with adb shell settings put global window_animation_scale 0, along with the transition and animator scales. Ask developers for an idle indicator if needed. Disabling animations makes tests faster and more stable, but keep one manual check of the real animations.
39

What is the difference between getText() and getAttribute()?

Save to ▾
Show answer
getText returns visible inner text; getAttribute returns an HTML attribute or property such as value, href or class.
40

How do you pass parameters from testng.xml?

Save to ▾
Show answer
Define parameter name and value in the XML and read them with @Parameters in the test or configuration method.

Frequently asked questions

What is asked in Automation Testing interviews for 2 years of experience?

At two years, you should contribute to the framework, not only write tests. Expect questions on Page Object Model, DataProvider, listeners, screenshots on failure, parallel runs and Jenkins jobs. Interviewers check that you can debug flaky tests and write REST Assured tests independently, with clean, reusable Java code.

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 2 years of experience?

Focus first on Page Object Model design, Listeners and reporting, REST Assured tests, Debugging flaky tests.