Skip to content

Automation Testing Online Assessment Questions & Answers

40 questions for the online assessment stage — 15 easy, 25 medium.

About the online assessment round

Most companies start with an online test: aptitude and reasoning, a few MCQs on core Automation Testing concepts, and one or two short hands-on tasks. It filters a large number of applicants, so speed and accuracy both count.

Tips for the online assessment round

  • Practise under a timer: about one minute per MCQ and 15-20 minutes per hands-on task.
  • Read every option before answering; tests often include two nearly correct choices.
  • Use a stable internet connection, keep your camera on and avoid switching tabs in proctored tests.
  • Attempt the questions you are sure about first, then return to the harder ones.
Solved — online assessmentStart 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

Should every test in a project be written in Cucumber?

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

How do you verify that an element is displayed, enabled or selected?

Save to ▾
Show answer
Use isDisplayed(), isEnabled() and isSelected() on the WebElement before interacting or asserting.
03

What are timers in JMeter and why is think time important?

Save to ▾
Show answer
By default JMeter fires requests back to back, which is far more aggressive than real users who read pages and fill forms. Timers add delays: Constant Timer, Uniform Random Timer and Gaussian Random Timer add think time, while Constant Throughput Timer and Precise Throughput Timer control request rate. Realistic think time makes the user count meaningful; without it, 100 threads may generate the load of thousands of real users.
04

What is the difference between extract().response() and extract().path()?

Save to ▾
Show answer
extract().response() returns the full Response object, so you can read status, headers, cookies, body as string, and use jsonPath() several times. extract().path("field") returns one value directly from the body. Use path() when you need a single value like an id or token, and response() when you need many details or want to log the response.
05

Your Jenkins test stage marks the build green even though tests failed. Why?

Save to ▾
Show answer
Possibly testFailureIgnore is set to true in Surefire, the shell step uses || true, or the script swallows Maven's exit code. Sometimes tests catch exceptions and never fail. Check the console log for Maven's BUILD result and Surefire summary. Fix the configuration so failures produce a non-zero exit, or use junit publishing to mark the build unstable when tests fail.
06

Write a REST Assured POST test that sends a JSON body and checks the response.

Save to ▾
Show answer
@Test public void createUser() { String body = "{\"name\":\"Ravi\",\"job\":\"QA\"}"; given() .baseUri("https://api.example.com") .contentType(ContentType.JSON) .body(body) .when() .post("/users") .then() .statusCode(201) .body("name", equalTo("Ravi")) .body("id", notNullValue()); }
07

You configured 50 parallel threads but only 8 tests run at a time on the Grid. Why?

Save to ▾
Show answer
The Grid only has 8 free slots, so the other requests wait in the New Session Queue. Total parallelism equals nodes multiplied by max sessions per node, not the TestNG thread count. Check the Grid UI for slot count. To run more, scale the node containers, raise max sessions if hardware allows, or use a larger grid. Otherwise reduce threads to match slots so waiting requests do not time out.
08

How do you run tests in parallel?

Save to ▾
Show answer
Use TestNG parallel="methods | classes | tests" with thread-count, keep WebDriver in a ThreadLocal, and use Selenium Grid or a cloud grid for multiple browsers.
09

Why is XPath slow in Appium and what should you use instead?

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

How do you handle waits inside page objects?

Save to ▾
Show answer
Put explicit waits in page methods or BasePage helpers, not in tests. For example click() waits for elementToBeClickable before clicking, and a page's isLoaded() waits for a key element. Avoid Thread.sleep and avoid mixing implicit and explicit waits. Keep the timeout configurable so CI can use a slightly longer value than local runs.
11

How do you group tests?

Save to ▾
Show answer
Tag tests with groups = {"smoke","regression"} and include or exclude them in testng.xml to run chosen sets.
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

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.
14

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.
15

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.
16

What is the difference between Scenario and Scenario Outline in Cucumber?

Save to ▾
Show answer
A Scenario runs once with fixed values. A Scenario Outline is a template with placeholders in angle brackets, and an Examples table supplies rows of data, so the same steps run once per row. Use an Outline when only the data changes, such as testing login with valid, locked and expired users. Avoid huge Examples tables; if data grows large, move it to an external source.
17

What is the difference between throw and throws?

Save to ▾
Show answer
throw actually raises an exception object inside a method; throws declares in the method signature that it may pass an exception to the caller.
18

What are stubs, mocks, fakes and spies in testing?

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

Write a simple page object class for a login page.

Save to ▾
Show answer
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); } }
20

A login action can lead either to the dashboard or to an error message. How should the page object method return?

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

What is the difference between @Test(priority) and dependsOnMethods in TestNG?

Save to ▾
Show answer
priority only orders tests; a lower number runs first, and a failed test does not stop the others. dependsOnMethods creates a real dependency: if the parent test fails, dependent tests are skipped. Both make tests order-dependent, which hurts parallel runs and isolation, so use them sparingly. Prefer independent tests with their own setup.
22

What are relative locators in Selenium 4?

Save to ▾
Show answer
Locators such as above, below, toLeftOf and near that find elements by their position relative to another element.
23

What is the difference between a Docker image and a container?

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

How do you pass thread count and duration to a JMeter test from the command line?

Save to ▾
Show answer
// In the Thread Group fields use property functions with defaults Number of Threads: ${__P(users,10)} Ramp-up period: ${__P(rampup,30)} Duration (seconds): ${__P(duration,300)} // Then override them when running jmeter -n -t load.jmx -l out.jtl -Jusers=200 -Jrampup=120 -Jduration=1800
25

How do you mock an external API in automation tests?

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

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.
27

Write a REST Assured test that deserializes a response into a POJO.

Save to ▾
Show answer
@Test public void getUserAsPojo() { User user = given() .pathParam("id", 2) .when() .get("/users/{id}") .then() .statusCode(200) .extract().as(User.class); Assert.assertEquals(user.getId(), 2); Assert.assertNotNull(user.getEmail()); }
28

How do you verify that the correct page has loaded in POM?

Save to ▾
Show answer
Give each page an isAt() or waitUntilLoaded() method that waits for a unique element, page title or URL fragment. Call it in the constructor or right after navigation. If it fails, throw a clear error such as "Expected Cart page but URL was /login". This catches navigation problems at the right point instead of failing later with a confusing locator error.
29

How do you resolve a merge conflict in Git?

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

How do you send form parameters and headers in REST Assured?

Save to ▾
Show answer
Use formParam("username", "asha") and formParam("password", "pass") for application/x-www-form-urlencoded bodies; REST Assured sets the content type for you. Add headers with header("X-Client", "web") or headers(map) for many at once. Cookies use cookie(name, value). Keep common headers in a RequestSpecification so individual tests only add what is specific to them.
31

Explain the given-when-then structure in REST Assured.

Save to ▾
Show answer
given() sets up the request: headers, params, body, auth. when() performs the HTTP call such as get(), post(), put() or delete(). then() validates the response: status code, headers, body using Hamcrest matchers, and response time. You can call extract() after then() to pull values for later steps. The fluent structure reads like a test specification and keeps setup, action and checks clearly separate.
32

What is Docker and how does it help tests?

Save to ▾
Show answer
Docker packages tools in containers so tests run identically everywhere; Selenium Grid and browsers can be started quickly in containers.
33

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.
34

How do you test negative scenarios for an API?

Save to ▾
Show answer
Send invalid or missing fields, wrong data types, values beyond limits, invalid IDs, expired or missing tokens, wrong HTTP methods and malformed JSON. Assert the correct status (400, 401, 403, 404, 405, 422) and a clear error body without stack traces. Negative tests often find more defects than happy paths because validation and security checks are frequently incomplete.
35

Write a step definition that reads a DataTable as a list of maps.

Save to ▾
Show answer
// Given the following users exist @Given("the following users exist") public void usersExist(DataTable table) { List<Map<String, String>> rows = table.asMaps(); for (Map<String, String> row : rows) { userApi.create(row.get("name"), row.get("role")); } }
36

What is a quality gate in a CI/CD pipeline?

Save to ▾
Show answer
A quality gate is a rule a build must pass before moving forward, such as all smoke tests passing, code coverage above a threshold, no critical static analysis issues, or no new high-severity vulnerabilities. If the gate fails, the pipeline stops and the change is not deployed. Gates make quality an automatic decision instead of a manual check.
37

What is the difference between a page object and a utility class in a test framework?

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

Write a Java stream that extracts and sorts product prices from a list of WebElements.

Save to ▾
Show answer
List<Double> prices = driver.findElements(By.cssSelector(".price")) .stream() .map(WebElement::getText) .map(t -> t.replaceAll("[^0-9.]", "")) .map(Double::parseDouble) .sorted() .collect(Collectors.toList()); System.out.println(prices);
39

What are Cucumber Expressions and how do they differ from regular expressions?

Save to ▾
Show answer
Cucumber Expressions are the default, simpler way to match steps, using parameter types like {int}, {string}, {word} and {float}. For example "I add {int} items" captures a number and converts it to an Integer automatically. Regular expressions are still supported and offer more control, but are harder to read. Teams usually prefer Cucumber Expressions and define custom parameter types for domain values.
40

Your code review shows a test class with 30 copy-pasted lines in every method. How do you refactor it with Java features?

Save to ▾
Show answer
Extract repeated steps into private helper methods or a page object, move common setup into @BeforeMethod, and use a DataProvider when only data differs. If the repeated code differs only in a small action, pass that action as a lambda, such as a Consumer<WebDriver>. Rerun the tests after each small refactor to confirm behaviour is unchanged.

Frequently asked questions

What happens in the Automation Testing online assessment round?

Most companies start with an online test: aptitude and reasoning, a few MCQs on core Automation Testing concepts, and one or two short hands-on tasks. It filters a large number of applicants, so speed and accuracy both count.

How do I clear the online assessment round?

Practise under a timer: about one minute per MCQ and 15-20 minutes per hands-on task. Read every option before answering; tests often include two nearly correct choices. Use a stable internet connection, keep your camera on and avoid switching tabs in proctored tests.

Which round comes next?

A typical order is online assessment, telephonic screening, one or two technical rounds, a managerial round and HR. Use the other round pages to practise each stage.