QA Interview
Junior SDET Selenium Pair Programming Interview Round (2026)
Prepare for a junior SDET Selenium pair programming interview round with 50+ Java questions, runnable exercises, debugging tactics, and grading criteria.
24 min read | 3,934 words
TL;DR
In a junior Selenium pairing round, build the smallest reliable test, explain why each locator and wait fits the UI state, and verify the business result. Interviewers grade collaboration and debugging judgment alongside working Java code.
Key Takeaways
- Clarify the success condition before creating a driver or choosing a locator.
- Complete one thin, runnable browser path before introducing framework abstractions.
- Use stable locators and explicit waits tied to observable application states.
- Assert the business outcome and guarantee driver cleanup after every run.
- Narrate decisions at useful checkpoints and test suggestions with small experiments.
- Debug with the exception, current context, DOM, screenshot, and environment evidence.
- Practice the exact Maven commands so setup does not consume the live exercise.
A junior sdet selenium pair programming interview round tests whether you can turn a small browser scenario into readable, reliable code while another engineer watches your decisions. To succeed, clarify the behavior, choose stable locators, synchronize with visible application states, assert the business result, and explain each tradeoff as you work.
This guide gives you a realistic 2026 question bank and a runnable Java project for rehearsal. It covers the coding task, collaboration signals, debugging follow-ups, refactoring choices, and the rubric interviewers commonly apply. Use the broader Selenium interview questions hub for theory review, then practice this material aloud with an editor and terminal open.
TL;DR
| Topic | What to demonstrate in the round | Evidence to show |
|---|---|---|
| Problem framing | Confirm inputs, expected result, and constraints | A short test outline before coding |
| Selenium fundamentals | Create and close a driver correctly | Clean setup and guaranteed teardown |
| Locators | Select unique, durable targets | IDs, names, or intentional attributes |
| Synchronization | Wait for the state the user needs | Explicit waits with meaningful conditions |
| Assertions | Check the business outcome | Exact confirmation text or persisted state |
| Pairing | Narrate choices and accept feedback | Small changes, questions, and quick reruns |
| Debugging | Diagnose from evidence | Exception, DOM, URL, screenshot, and logs |
Treat the exercise as collaborative production work, not a race to type syntax. A complete small test with a clear assertion is stronger than a large framework that never runs.
1. Junior SDET Selenium Pair Programming Interview Round Format
Q: What is the interviewer actually measuring in a pair programming round?
The interviewer is measuring how you translate a requirement into executable evidence, not merely whether you remember Selenium methods. They watch how you reduce ambiguity, name code, handle failure, and respond when an assumption is challenged. A junior candidate earns confidence by producing a small correct path and showing a safe way to extend it.
Q: How should you begin when the prompt says, "Automate this login flow"?
Restate the success path with concrete preconditions, actions, and outcomes before opening the driver. Ask whether credentials are supplied, whether a failed-login case is in scope, and which page state proves authentication. Then write one happy-path test first so the pair has a shared, runnable baseline.
Q: Should you talk continuously while writing code?
Narrate decisions at transition points rather than reading every character you type. Explain why a locator is stable, what condition a wait represents, and what an assertion proves. Leave quiet space for implementation, then invite feedback when you have a compilable increment.
Q: What should you do if you forget an exact API signature?
Say the class or behavior you intend to use, then consult IDE completion or official documentation if the exercise allows it. For example, remembering that WebDriverWait takes a driver and Duration shows the right model even if an import slips your mind. Never invent a method and continue as though it exists, because correction skill is part of the evaluation.
2. Project Setup and WebDriver Lifecycle
Q: What minimal Java project should you prepare for practice?
Use JDK 21, Maven, Selenium Java, JUnit Jupiter, and a locally installed Chrome or Chromium browser. Selenium Manager is included with Selenium and can resolve an appropriate driver when you create ChromeDriver, so old tutorials that manually set webdriver.chrome.driver are usually unnecessary. Put tests under src/test/java and confirm the toolchain before the interview with java -version and mvn -version.
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qajobfit</groupId>
<artifactId>selenium-pair-practice</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<selenium.version>4.47.0</selenium.version>
<junit.version>6.1.3</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.6</version>
</plugin>
</plugins>
</build>
</project>
Verify dependency resolution with mvn -q -DskipTests test. A zero exit code shows that Maven compiled the project model and obtained the declared libraries.
Q: Why is driver teardown part of the coding assessment?
A leaked browser process consumes memory and can affect later tests or CI agents. Put driver.quit() in an @AfterEach method or a finally block so cleanup still runs after an assertion or locator failure. Reliable resource ownership is a basic engineering signal, even when the exercise lasts only thirty minutes.
Q: What is the difference between close() and quit()?
close() closes the current top-level browsing context, which is normally one tab or window. quit() ends the WebDriver session and closes every context associated with it. Use quit() for test teardown, while close() is useful only when the scenario deliberately closes one secondary window and continues in another.
Q: Should a junior candidate configure headless mode immediately?
Start with a visible browser during pairing unless the interviewer requests headless execution. Seeing the interaction speeds diagnosis of overlays, navigation mistakes, and focus problems. Once the test passes, you can add ChromeOptions for headless CI execution and rerun to prove the behavior does not depend on observation.
3. Locators in a Junior SDET Selenium Pair Programming Interview Round
Q: Which locator should you choose first?
Prefer a unique, stable ID, name, or product-owned test attribute that expresses the element's purpose. If those are unavailable, scope a short CSS selector to a meaningful component or use relative XPath when relationships or text are essential. The choice should survive unrelated styling and layout changes.
Q: Is CSS always better than XPath?
No, that claim replaces analysis with a slogan. CSS is concise for attributes and hierarchy, while XPath can express ancestor, sibling, and normalized-text relationships that CSS cannot always express cleanly. Judge a selector by uniqueness, stability, readability, and how closely it represents the user's intended control.
Q: How do you handle a dynamic ID such as user_48291_save?
First ask whether the application team can expose a stable data-testid or semantic attribute. If the stable prefix is contractual, a CSS selector such as button[id^='user_'][id$='_save'] may work, but it could still match several rows. Scope the query to the known user row and verify that exactly one save control is found.
Q: How do findElement and findElements differ?
findElement returns the first match and throws NoSuchElementException when no node matches. findElements returns a list and gives an empty list when nothing matches, which is useful for optional content and collections. Do not use the plural method merely to suppress a failure when the page contract requires exactly one element.
Q: How would you prove that a locator is good during the interview?
Inspect its match count in browser developer tools or query through WebDriver before using it in a critical action. Explain which attribute is controlled by the product and which DOM changes would invalidate the selector. For deeper locator drills, compare your approach with these dynamic XPath examples in Java.
4. Waits and Dynamic UI Synchronization
Q: What is the practical difference between implicit and explicit waits?
An implicit wait changes how long element lookup polls across the session. An explicit wait repeatedly evaluates one named condition, such as visibility, text, or staleness, until it succeeds or times out. Keep implicit wait at zero in an explicit-wait design because nested timeouts make failure duration difficult to predict.
Q: Why is Thread.sleep a weak solution?
Thread.sleep waits for elapsed time rather than a meaningful application state. It always consumes the full delay when the page is fast and still fails when the page is slower than the guess. Replace it with a condition that describes what the next action genuinely requires.
Q: Is elementToBeClickable enough to prove that a click will succeed?
elementToBeClickable checks that an element is visible and enabled, but it does not guarantee that an animation, transparent overlay, or sticky header will not intercept the pointer. When the application has a loading mask, wait for that mask to become invisible as a separate state. After clicking, assert the resulting page change so a silent no-op cannot pass.
Q: How should you handle StaleElementReferenceException?
Identify the navigation or re-render that detached the stored node. Wait for the old element to become stale when that transition is expected, then locate its replacement from the current DOM. Avoid a broad retry loop around clicks because it can repeat purchases, submissions, or other side effects.
Q: Can you show a runnable explicit-wait test?
The following test uses a data URL, so it needs no external test site and directly demonstrates a delayed DOM state. The lambda is side-effect free and returns true only when the status text becomes Complete. Create the file at src/test/java/interview/DynamicWaitTest.java.
package interview;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
class DynamicWaitTest {
@Test
void waitsForBusinessState() {
String html = """
<p id="status">Queued</p>
<script>
setTimeout(() => {
document.querySelector('#status').textContent = 'Complete';
}, 500);
</script>
""";
String encoded = Base64.getEncoder().encodeToString(
html.getBytes(StandardCharsets.UTF_8)
);
String url = "data:text/html;base64," + encoded;
WebDriver driver = new ChromeDriver();
try {
driver.get(url);
new WebDriverWait(driver, Duration.ofSeconds(3))
.until(d -> d.findElement(By.id("status")).getText().equals("Complete"));
assertEquals("Complete", driver.findElement(By.id("status")).getText());
} finally {
driver.quit();
}
}
}
Verify it with mvn -q -Dtest=DynamicWaitTest test. The process should exit successfully, and removing the JavaScript update should produce a TimeoutException instead of a false pass. Review additional timing cases in the Selenium waits scenario interview guide.
5. Writing the Core Selenium Exercise
Q: What should the first runnable test contain?
Include browser creation, navigation, one purposeful interaction, an explicit wait, a business assertion, and guaranteed cleanup. Keep the path narrow enough to finish before extracting helpers. This complete example uses Selenium's public web form and can run against the Maven project above.
package interview;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.Duration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
class WebFormPairTest {
private WebDriver driver;
@AfterEach
void stopBrowser() {
if (driver != null) {
driver.quit();
}
}
@Test
void submitsTheWebForm() {
driver = new ChromeDriver();
driver.get("https://www.selenium.dev/selenium/web/web-form.html");
driver.findElement(By.name("my-text")).sendKeys("junior-sdet");
driver.findElement(By.cssSelector("button")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
String message = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.id("message"))
).getText();
assertEquals("Received!", message);
}
}
Run mvn -q -Dtest=WebFormPairTest test and expect one passing test. If Chrome cannot start, diagnose the browser installation and Selenium Manager output instead of changing test logic blindly.
Q: Why does this test assert text instead of only the URL?
A URL change can occur before the requested operation finishes or can lead to an error page on the same route pattern. The confirmation message is the observable contract offered by this sample form. In a real product, strengthen the check with persisted data or a domain-specific status when that evidence is available.
Q: When should you refactor during a timed exercise?
Refactor after the smallest end-to-end test runs and the duplication or abstraction boundary is visible. Extract a locator, method, or page object when it improves the next change, not because frameworks are expected. Run the test after each structural edit so behavior remains anchored.
Q: How should you respond when your pair suggests a different approach?
Restate the suggestion to confirm you understood its goal, then compare it against the requirement. If it improves clarity or reliability, implement the smallest version and rerun immediately. If you see a risk, demonstrate it with a locator match, failure mode, or focused experiment rather than defending your first idea emotionally.
Q: What Java fundamentals may appear inside the Selenium task?
Expect collections, streams, strings, exceptions, classes, and simple control flow around browser elements. You might filter rows, map text values, select a matching item, or create a reusable page method. Prepare with core Java interview questions for Selenium testers, but favor readable loops over clever one-liners when pairing.
6. Page Objects and Maintainable Refactoring
Q: What is a Page Object in practical terms?
A Page Object provides a focused interface for the operations and state of one page or reusable component. It centralizes important locators and lets tests speak in domain actions such as submitName rather than repeat low-level commands. It is a design boundary, not a requirement to wrap every WebElement.
Q: Should assertions live inside the Page Object?
Keep scenario-level assertions in the test so the expected behavior remains visible to the reader. A page method can verify an operational precondition, such as waiting until a form is ready, and it can return state for the test to assert. Avoid methods named verifyEverything because they hide which contract failed.
Q: How small can a useful Page Object be?
It can be one class with two locators, one action, and one state-reading method. The example below deliberately nests the page class so the file is independently runnable, while a real project would place it in its own production or test source file. Its constructor receives WebDriver, which keeps browser ownership in the test.
package interview;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
class PageObjectPairTest {
static final class WebFormPage {
private final WebDriver driver;
private final WebDriverWait wait;
private final By textInput = By.name("my-text");
private final By submit = By.cssSelector("button");
private final By message = By.id("message");
WebFormPage(WebDriver driver) {
this.driver = driver;
this.wait = new WebDriverWait(driver, Duration.ofSeconds(5));
}
void open() {
driver.get("https://www.selenium.dev/selenium/web/web-form.html");
}
void submitName(String name) {
driver.findElement(textInput).sendKeys(name);
driver.findElement(submit).click();
}
String confirmation() {
return wait.until(
ExpectedConditions.visibilityOfElementLocated(message)
).getText();
}
}
@Test
void submitsThroughPageObject() {
WebDriver driver = new ChromeDriver();
try {
WebFormPage page = new WebFormPage(driver);
page.open();
page.submitName("pair-candidate");
assertEquals("Received!", page.confirmation());
} finally {
driver.quit();
}
}
}
Verify the refactor with mvn -q -Dtest=PageObjectPairTest test. The same user behavior should pass while the test now reads at a higher level.
Q: What Page Object design mistake should a junior avoid?
Do not build a BasePage containing dozens of unrelated clicks, waits, JavaScript utilities, and assertions. That inheritance structure hides dependencies and turns changes into global risk. Prefer small page or component objects composed around actual UI responsibilities, as shown in the Selenium Java framework guide.
7. Forms, Frames, Alerts, Windows, and Files
Q: How do you automate a native dropdown?
Locate the select element and wrap it with Selenium's Select class. Choose by visible text or stable value, then assert firstSelectedOption rather than assuming the click worked. If the control is built from div and button elements, interact with its accessible trigger and option nodes because Select only supports an HTML select.
Q: How do you work inside an iframe?
Wait for the frame and switch to it before locating its internal content. Perform the scoped actions, then return through switchTo().defaultContent() so later locators search the top document. A NoSuchElementException inside a visually obvious frame often indicates wrong context rather than a bad selector.
Q: How do you handle a JavaScript alert?
Wait until the alert is present, switch to it, read its text, and then accept or dismiss according to the scenario. Normal page commands are blocked while a modal alert is active. Validate what changes after the response, such as a status label, instead of treating alert closure as the final result.
Q: How do you switch to a newly opened tab?
Save the original window handle, trigger the new tab, and wait until the handle count reaches the expected value. Select the handle that differs from the original, switch to it, and verify a title or URL before continuing. When finished, close the secondary context and explicitly switch back, since Selenium does not automatically restore focus.
Q: How should file upload be automated?
Send the absolute file path directly to the input element whose type is file. Do not automate the operating system chooser, because it sits outside WebDriver's browser DOM model and behaves differently across machines. Before the test, create a known fixture and after upload assert the filename, preview, or server-side result.
8. Debugging and Flaky Test Diagnosis
Q: What is your first move after NoSuchElementException?
Read the first relevant stack frame and confirm the current URL, title, window, and frame context. Check whether the locator matches zero nodes now, appears later, or points at a different page state. Only after identifying the missing assumption should you alter a selector or add a wait.
Q: How do you investigate ElementClickInterceptedException?
Capture a screenshot and inspect which element occupies the target coordinates. Common causes include loading masks, cookie banners, sticky headers, and unfinished animation. Wait for the specific blocker to disappear or fix the product defect, then confirm that the intended post-click state occurred.
Q: When is JavaScript click acceptable?
Use it only when the product intentionally exposes an interaction that a real pointer cannot perform and the team accepts the reduced fidelity. A JavaScript click bypasses parts of WebDriver's interactability model, so it can conceal an inaccessible or covered control. Document the reason and retain an assertion that detects whether the application processed the event.
Q: How do you diagnose a test that passes locally but fails in CI?
Compare browser versions, window size, locale, time zone, network access, CPU pressure, and test data between environments. Collect the failing screenshot, page source or targeted DOM, console output where supported, and exact exception rather than relying on the final assertion alone. Reproduce the CI configuration locally or in a container before increasing timeouts.
Q: Are automatic retries a good fix for flaky tests?
Retries can measure instability or reduce temporary noise, but they do not repair an unknown race or shared-data collision. Record both the first failure and the retry outcome so the problem remains visible. Quarantine a genuinely disruptive test with ownership and a deadline, then fix its state model instead of normalizing intermittent results.
9. Test Design, Git, and CI Judgment
Q: Which scenario should you automate first?
Choose a repeatable, business-critical flow with deterministic outcomes and a reasonable maintenance cost. Confirm that browser automation is the right layer, because validation rules and service contracts are often faster at unit or API level. In a short interview, a focused smoke path is more valuable than claiming exhaustive UI coverage.
Q: What makes Selenium tests independent?
Each test controls its preconditions, owns mutable data, and does not depend on execution order. Use unique identifiers when parallel workers might touch the same records, and clean up through a reliable API or fixture when necessary. Independence allows one test to run alone and makes failures easier to attribute.
Q: What should a candidate commit during a pairing exercise?
Commit a coherent passing increment with a short imperative message such as "Add web form submission test." Do not mix generated files, IDE settings, and unrelated refactors into the same change. Before committing, inspect the diff for credentials, accidental sleeps, debug prints, and files outside the requested scope.
Q: What changes when the test runs in CI?
Run headlessly if required, pin or record important tool versions, and make browser configuration explicit. Emit useful artifacts on failure while keeping secrets out of screenshots and logs. Use TestNG interview questions and answers if the role names TestNG, but apply the same isolation and lifecycle principles regardless of runner.
10. Junior SDET Selenium Pair Programming Interview Round Scenarios
Q: How would you click Edit for the row containing user alex?
Locate the table rows, inspect the cell that contains the stable user identifier, and keep the search scoped to the matching row. Then find the Edit button inside that row rather than choosing a global button index. If no row matches, fail with a message that names alex and the observed row values.
Q: How would you automate an autocomplete field?
Type a distinctive query, wait for the listbox to become visible, and wait until its options contain the intended label. Click the matching option by role or stable attribute, then verify the input's selected value or the resulting record. Do not press ArrowDown a fixed number of times because ranking and existing history can change order.
Q: What would you do when a save button becomes enabled only after validation?
Fill each required field using data that exercises the intended rule, then wait for the button's enabled state. Click once and assert a server-confirmed success indicator or persisted value. If the button never enables, inspect inline validation messages before increasing the wait.
Q: How would you repair a test that stores WebElements before a React rerender?
Store locators or domain identifiers instead of long-lived WebElement references across the update. Wait for the old node to become stale or for a new application state, then locate the current element. This makes the transition explicit and avoids hiding a recurring rerender behind a blanket stale-element retry.
Interview Questions and Answers
Q: What is Selenium WebDriver?
Selenium WebDriver is an API for automating browser behavior through standardized commands. It supports navigation, element discovery, user interactions, and browsing-context control. A test runner supplies discovery, fixtures, assertions, and reporting around those commands.
Q: What does Selenium Manager do?
Selenium Manager is Selenium's built-in tool for driver and browser management in supported configurations. It is invoked when the bindings need to resolve an appropriate local driver, which removes much manual executable-path setup. Network restrictions or unsupported installations can still require explicit environment preparation.
Q: What is the Page Object Model?
Page Object Model organizes page or component behavior behind a small interface used by tests. It localizes important selectors and reduces repeated interaction sequences. A healthy page object represents user-facing operations without becoming a universal utility class.
Q: What does presence mean compared with visibility?
Presence means a matching node exists in the DOM. Visibility additionally requires the element to be displayed with a nonzero size, which is closer to many user interactions. Neither state alone guarantees that an overlay will not intercept a click.
Q: How do you verify a successful login?
Assert an authenticated state that an anonymous user cannot see, such as an account identifier and a protected page response. A URL check can support that evidence but should not be the only proof. Avoid asserting transient loading text that can appear before authentication completes.
Q: Why should implicit and explicit waits not be mixed?
An explicit condition can perform element lookups that inherit the implicit timeout. The nested polling makes the actual maximum duration surprising and slows diagnosis. Set implicit waiting to zero when each dynamic state has an intentional explicit condition.
Q: What belongs in a useful failure report?
Include the scenario and data identity, exception with relevant stack trace, current URL, timestamp, browser details, and a screenshot. Add targeted DOM or console evidence when it helps explain the failure. Redact tokens, personal data, and passwords before artifacts leave the test environment.
Q: How do you decide whether a failure is a product bug or a test bug?
Compare the documented expectation with direct observation using the same environment and data. If the product violates the requirement outside automation, file a product defect with reproducible evidence. If the script used a false assumption about timing, context, selector, or data, repair the test and add a check that exposes that assumption.
How Interviewers Grade Your Answers
Interviewers usually score several signals together rather than awarding points for a memorized framework name.
| Signal | Strong evidence | Concern |
|---|---|---|
| Requirement analysis | Defines success and asks bounded questions | Starts clicking with hidden assumptions |
| Correctness | Code compiles, runs, and asserts the requested result | Stops after an action without verification |
| Selenium judgment | Uses durable locators and state-based waits | Relies on absolute XPath and sleeps |
| Java quality | Clear names, small methods, safe cleanup | Broad catches or mutable global state |
| Pairing | Explains choices, listens, and incorporates feedback | Goes silent or argues without evidence |
| Debugging | Uses exception and artifacts to test a hypothesis | Randomly changes timeouts and selectors |
| Scope control | Finishes a thin vertical slice before extras | Builds abstractions while the core test is broken |
A junior candidate is not expected to design a company-wide grid in one sitting. Interviewers want trustworthy fundamentals, teachability, and a working result. You can rehearse the communication component through QA interview practice and use the resume upload dashboard to make sure every Selenium claim on your resume can survive follow-up questions.
Common Mistakes
- Coding before confirming what proves success.
- Choosing a long absolute XPath copied from developer tools.
- Adding Thread.sleep after every interaction.
- Mixing implicit waits with multiple explicit wait layers.
- Calling close() in teardown and leaving the session alive.
- Catching Exception, printing it, and allowing the test to pass.
- Reusing data that collides during parallel execution.
- Forcing JavaScript click before inspecting an overlay.
- Moving all assertions into a large Page Object.
- Refactoring before one end-to-end path works.
- Claiming Grid, CI, or framework ownership without implementation details.
- Ignoring the pair's feedback while optimizing syntax.
- Ending the exercise without running the test from a clean command.
- Logging credentials or tokens in failure artifacts.
Correct these mistakes by working in visible increments. State the next intended result, make one change, run the narrowest useful command, and interpret the output before proceeding.
Conclusion
A strong junior SDET Selenium pair programming interview round performance combines a small working test with disciplined communication. Practice driver lifecycle, locators, explicit waits, assertions, context switching, and evidence-based debugging until you can explain them while coding.
Build the three examples in this guide, deliberately break one locator and one wait, then repair each failure aloud. That rehearsal shows more job-ready ability than memorizing dozens of disconnected Selenium definitions.
Interview Questions and Answers
How would you start a Selenium pair programming task?
I would restate the scenario as preconditions, actions, and one observable success condition. Then I would confirm the browser, language, and any constraints on libraries or documentation. I would implement the thinnest complete path and run it before refactoring.
Why do you prefer explicit waits?
An explicit wait names the exact state required by the next step and returns as soon as that state is ready. It produces a meaningful timeout when the state never occurs. I avoid combining it with a nonzero implicit wait because total timing becomes difficult to reason about.
How do you choose a Selenium locator?
I look for a unique attribute whose stability is controlled by the product, such as an ID, name, or dedicated test hook. If none exists, I use a short scoped CSS selector or a relationship-based XPath. I confirm uniqueness and avoid positional paths tied to layout.
What is the difference between driver.close and driver.quit?
driver.close ends only the current tab or window. driver.quit terminates the full WebDriver session and all associated browsing contexts. Test teardown normally calls quit so it does not leak browser processes.
How do you handle StaleElementReferenceException?
I find the rerender or navigation that detached the original node. If the replacement is expected, I wait for the transition and locate the element again from the updated DOM. I do not retry every action blindly because repeated side effects may corrupt the scenario.
Where should assertions live in a Page Object design?
Business expectations should remain in the test where the scenario is readable. Page methods can wait for operational readiness and return state such as confirmation text. This separation lets the same page behavior support different test expectations.
How would you debug ElementClickInterceptedException?
I would inspect a screenshot and the DOM to identify what covered the intended control. Then I would synchronize with that specific blocker or report the product issue if the element is genuinely unusable. I would verify the post-click result instead of immediately forcing a JavaScript event.
What makes a UI test independent?
The test creates or controls its own preconditions and does not rely on another test's execution. Mutable data is isolated with unique values or cleanup. The scenario can run alone, in a different order, or on a parallel worker.
How do you handle a new browser tab?
I save the current handle, trigger the new context, and wait for the expected handle count. I switch to the handle not present before the action and verify its page identity. After closing it, I explicitly restore the original context.
When is JavaScript click justified?
It is a last-resort choice for an intentionally script-driven control that the team has confirmed cannot be operated through normal WebDriver interaction. I document why pointer fidelity is being bypassed. I still assert the application result and investigate accessibility implications.
What artifacts do you capture for a Selenium failure?
I capture the exception, current URL, browser metadata, screenshot, and relevant page or console evidence. Each artifact is labeled with the scenario and safe test-data identifier. Secrets and personal information are redacted before storage or sharing.
How do you show good pairing behavior while coding?
I make assumptions visible, explain decisions at meaningful checkpoints, and keep increments runnable. When my partner suggests a change, I test it against the requirement and incorporate useful feedback promptly. I also summarize the current state before moving into a larger refactor.
Frequently Asked Questions
What happens in a junior SDET Selenium pair programming interview?
You usually share an editor with an interviewer and automate a small browser flow while discussing decisions. The interviewer may introduce a failing locator, asynchronous element, or refactoring request. They assess working code, test judgment, communication, and response to feedback.
Which language should I use for a Selenium pair programming round?
Use the language requested by the job description or agreed with the interviewer. Java is common, so know its test runner, collections, exceptions, build commands, and Selenium bindings. Choose the option you can debug confidently rather than the one that sounds most advanced.
How much Selenium coding is expected from a junior SDET?
Expect to create a driver, locate elements, perform common interactions, wait for dynamic state, and assert an outcome. A short data or table exercise may test basic Java reasoning. Senior-scale framework or Grid architecture is uncommon unless the role description explicitly asks for it.
Can I use documentation during a pair programming interview?
The policy varies, so ask before the timer starts. Many interviewers allow API documentation because they care more about reasoning than perfect import recall. Explain what you are looking up and return quickly to the task.
Should I use Page Object Model in a short Selenium exercise?
Only introduce a Page Object after the basic flow works or when the prompt explicitly requires one. A small object can improve naming and isolate locators. Building a framework before proving the scenario can consume the session without delivering evidence.
How do I practice Selenium live coding at home?
Create a Maven project and rehearse one form, one delayed element, one table, and one window-switching task. Run every example from the terminal so dependency or browser issues surface early. Record yourself explaining assumptions and diagnosing deliberate failures.
What if my Selenium test fails during the interview?
Treat the failure as part of the exercise and read the exact exception first. Check page state, context, locator matches, and timing before editing. A structured diagnosis can demonstrate stronger engineering judgment than an immediate pass.
Related Guides
- Principal SDET Java Pair Programming Interview Questions (2026)
- Test Architect TypeScript Pair Programming Interview Round (2026)
- Cypress TypeScript Pair Programming Interview Questions (2026)
- Junior SDET Playwright Trace Debugging Interview Questions (2026)
- Playwright TypeScript Pair Programming Interview Questions (2026)
- Principal SDET Observability Debugging Interview Round (2026)