SoftwareTestPilot
80 curated Selenium Q&A

Selenium Interview Questions & Answers (2026) — Crack Your Next SDET Round

A curated Selenium hub, split by experience level — jump straight to Fresher (0–1 yrs), Mid-level (2–4 yrs) or Senior/SDET (5+ yrs). We cut a 300-question dump down to the 80 questions hiring managers actually ask, each with a senior-level answer and Java code sample. Covers fundamentals, locators, waits, frameworks, Selenium Grid, Selenium 4, CI/CD, and scenario-based problem solving — for freshers through SDET architects.

  • 28 min read
  • Difficulty: Mixed (Easy → Hard)
  • Freshers → 10+ yrs
  • Updated June 2026
  • Avinash Kamble
Avinash Kamble
Founder & QA Engineer at SoftwareTestPilot
Published:
Benchmarks

Selenium market & interview benchmarks (2026)

Reference numbers you can cite in interviews and blog posts. Aggregated from the QA Jobs Radar live feed (India + US postings scraped Jan–Jun 2026), Stack Overflow 2026 developer survey, and Selenium 4.x adoption telemetry across ~1,200 SoftwareTestPilot readers.

MetricIndiaUnited StatesGlobal avg.
Open SDET roles requiring Selenium (Jun 2026)4,8203,61011,400+
Selenium vs Playwright job-req ratio3.1 : 12.6 : 12.9 : 1
Median SDET salary (Selenium primary, 3–5 YOE)₹14.8 LPA$118,500
Median SDET salary (Selenium primary, 5–8 YOE)₹24.5 LPA$142,000
% of postings requiring Selenium Grid 438%44%41%
% of postings requiring TestNG + POM72%58%65%
% of postings requiring CDP / Selenium 4 APIs21%29%24%
Avg. interview rounds for Selenium SDET454.3
Live-coding round frequency68%81%73%
Framework-design round frequency (5+ YOE)91%88%90%

Swipe horizontally to see all columns →

Read

Selenium still outnumbers Playwright ~3:1 in real 2026 postings, and framework-design questions are now table-stakes past 5 YOE. If you have <5 YOE, prioritise Grid 4 + TestNG + POM; past 5 YOE, own CDP, parallelisation, and CI design.

0 / 80 reviewed
0%

1. Fresher (0–1 yrs)

Easy Very Common 1 minQ1 / 80

Q1.What is Selenium?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Interviewers open with "Selenium" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Selenium is an open-source suite for automating web browsers. Its main component, Selenium WebDriver, is a W3C standard API implemented by every major browser. Freshers use it to write scripts in Java, Python, JavaScript, C#, or Ruby.

Tips to remember
  • Open with a one-sentence definition of Selenium, then a concrete Selenium example — never start with history or theory.
  • Keep the answer to 60–90 seconds; anything longer signals you can't summarise Selenium cleanly.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
RelatedQ3
Easy Very Common 1 minQ2 / 80

Q2.What are the components of Selenium?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Interviewers open with "components of Selenium" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation
  1. Selenium IDE — record-and-playback browser extension
  2. Selenium WebDriver — code-first API (the main one)
  3. Selenium Grid — distributed / parallel execution
Tips to remember
  • Open with a one-sentence definition of components of Selenium, then a concrete Selenium example — never start with history or theory.
  • Group the components of Selenium points into 2–3 buckets so you can recall them under pressure without missing one.
  • Call out test isolation and shared-state risk (data, sessions, ports) before you talk about worker counts.
Easy Very Common 1 minQ3 / 80

Q3.What is WebDriver?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Interviewers open with "WebDriver" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

The W3C-standard programming interface for controlling a browser. Each browser ships its own driver (ChromeDriver, GeckoDriver, EdgeDriver) that translates WebDriver commands into browser-native actions.

Tips to remember
  • Open with a one-sentence definition of WebDriver, then a concrete Selenium example — never start with history or theory.
  • Keep the answer to 60–90 seconds; anything longer signals you can't summarise WebDriver cleanly.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Medium Very Common 1 minQ4 / 80

Q4.How do you set up Selenium with Java + Maven?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you set up Selenium with Java + Maven" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.28.0</version>
</dependency>
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");
driver.quit();
Tips to remember
  • Walk through set up Selenium with Java + Maven as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the set up Selenium with Java + Maven snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Medium Very Common 1 minQ5 / 80

Q5.Do you still need to download ChromeDriver manually?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

This Selenium question checks whether you can go beyond textbook knowledge on Do you still need to download ChromeDriver manually and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

No — Selenium 4.6+ ships Selenium Manager, which auto-downloads the right driver. You just do new ChromeDriver().

Tips to remember
  • Anchor the answer in a real Selenium project — panels reward specificity on Do you still need to download ChromeDriver manually over textbook wording.
  • Be ready to whiteboard the Do you still need to download ChromeDriver manually snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Medium Very Common 1 minQ6 / 80

Q6.What's the difference between driver.close() and driver.quit()?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Comparison questions like this test whether you understand driver.close() vs driver.quit() at a design level — not just that both exist, but when to pick one over the other. Panels use it to see if you can defend a trade-off with a real project example.

Detailed explanation

close() closes the current tab. quit() closes all tabs and ends the WebDriver session. Always quit() in @AfterMethod to avoid leaked browser processes.

Tips to remember
  • Structure the answer as a small table in your head: dimension, option A, option B — and close with "I'd pick X when Y".
  • Be ready to whiteboard the driver.close() vs driver.quit() snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Easy Very Common 1 minQ7 / 80

Q7.What locator strategies does Selenium support?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

This Selenium question checks whether you can go beyond textbook knowledge on What locator strategies does Selenium support and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation
  • id, name, className, tagName
  • linkText, partialLinkText
  • cssSelector, xpath
  • Selenium 4 relative locators: above/below/toLeftOf/toRightOf/near
Tips to remember
  • Anchor the answer in a real Selenium project — panels reward specificity on What locator strategies does Selenium support over textbook wording.
  • Group the What locator strategies does Selenium support points into 2–3 buckets so you can recall them under pressure without missing one.
  • Say explicitly that you prefer CSS/relative locators and only fall back to XPath for text or axes — panels grade locator hygiene here.
Easy Very Common 1 minQ8 / 80

Q8.CSS selector vs XPath — which is better?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Comparison questions like this test whether you understand CSS selector vs XPath — which is better at a design level — not just that both exist, but when to pick one over the other. Panels use it to see if you can defend a trade-off with a real project example.

Detailed explanation

Prefer CSS: shorter, faster, cleaner. Use XPath when you need text(), parent axis, or starts-with. Never chain 6 levels of XPath — use test IDs instead.

Tips to remember
  • Structure the answer as a small table in your head: dimension, option A, option B — and close with "I'd pick X when Y".
  • Keep the answer to 60–90 seconds; anything longer signals you can't summarise CSS selector vs XPath — which is better cleanly.
  • Say explicitly that you prefer CSS/relative locators and only fall back to XPath for text or axes — panels grade locator hygiene here.
Medium Very Common 1 minQ9 / 80

Q9.Explain the difference between driver.close() and driver.quit().

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Comparison questions like this test whether you understand difference between driver.close() and driver.quit() at a design level — not just that both exist, but when to pick one over the other. Panels use it to see if you can defend a trade-off with a real project example.

Detailed explanation

driver.close() closes only the current active browser tab or window where WebDriver currently has focus, leaving the underlying browser driver session active if other windows remain open. In contrast, driver.quit() closes every open browser window, terminates the native browser process, and completely destroys the WebDriver session on the OS. Forgetting to call driver.quit() in teardown hooks causes zombie chromedriver processes to accumulate on CI/CD runner nodes, exhausting server memory.

driver.quit(); // Closes all windows and terminates session safely
Tips to remember
  • Structure the answer as a small table in your head: dimension, option A, option B — and close with "I'd pick X when Y".
  • Be ready to whiteboard the difference between driver.close() and driver.quit() snippet live — panels often ask you to type it, not describe it.
  • Describe the pipeline stage order and what makes the build fail — a vague "we run tests in CI" answer stalls here.
Medium Very Common 1 minQ10 / 80

Q10.How do findElement() and findElements() behave when a DOM locator has zero matches?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Hands-on "how would you How do findElement() and findElements() behave when a DOM locator has zero matches" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

findElement() immediately throws a NoSuchElementException if the element is not present in the DOM when polling concludes. Conversely, findElements() never throws NoSuchElementException when matches are absent; instead, it returns an empty Java List<WebElement> with size zero. Experienced engineers leverage findElements().isEmpty() to verify absence of elements without writing try-catch blocks around findElement().

List<WebElement> list = driver.findElements(By.id("optional"));
boolean isAbsent = list.isEmpty();
Tips to remember
  • Walk through How do findElement() and findElements() behave when a DOM locator has zero matches as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the How do findElement() and findElements() behave when a DOM locator has zero matches snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Hard Very Common 1 minQ11 / 80

Q11.What is the difference between Implicit Wait, Explicit Wait (WebDriverWait), and FluentWait?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Interviewers open with "difference between Implicit Wait, Explicit Wait (WebDriverWait), and FluentWait" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Implicit wait sets a global DOM polling duration for element presence across all findElement calls. Explicit wait (WebDriverWait) pauses execution until a specific ExpectedCondition (such as visibility or clickability) evaluates to true for a particular element. FluentWait is the parent implementation of WebDriverWait that allows custom configuration of polling frequency and specific exception ignoring (e.g., ignoring ElementClickInterceptedException while waiting).

Wait<WebDriver> wait = new FluentWait<>(driver)
    .withTimeout(Duration.ofSeconds(20))
    .pollingEvery(Duration.ofMillis(500))
    .ignoring(NoSuchElementException.class);
Tips to remember
  • Open with a one-sentence definition of difference between Implicit Wait, Explicit Wait (WebDriverWait), and FluentWait, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the difference between Implicit Wait, Explicit Wait (WebDriverWait), and FluentWait snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Hard Very Common 1 minQ12 / 80

Q12.Why does mixing Implicit and Explicit waits cause unpredictable WebDriver delays?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

"Why" questions on es mixing Implicit and Explicit waits cause unpredictable WebDriver delays probe your reasoning, not your memory. Strong candidates connect the choice to a business or reliability outcome — flaky tests, slower feedback loop, or missed defects — instead of parroting a rule.

Detailed explanation

When implicit and explicit waits are mixed, browser drivers experience timeout collision. If an implicit wait of 10 seconds is set globally alongside an explicit wait of 15 seconds, the driver may poll the implicit wait full duration on every internal lookup triggered by the explicit wait condition. This can cause a simple 15-second explicit wait to block thread execution for over 150 seconds under failure conditions.

// NEVER mix: driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
// Standardize on explicit waits exclusively:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
Tips to remember
  • Tie the "why" for es mixing Implicit and Explicit waits cause unpredictable WebDriver delays back to a measurable outcome — flake rate, execution time, defect leakage — instead of an opinion.
  • Be ready to whiteboard the es mixing Implicit and Explicit waits cause unpredictable WebDriver delays snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Medium Very Common 1 minQ13 / 80

Q13.How do you select an option from a standard HTML <select> dropdown?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you select an option from a standard HTML <select> dropdown" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

When automating standard DOM <select> elements, Selenium provides the org.openqa.selenium.support.ui.Select wrapper class. Engineers pass the located WebElement into the Select constructor and invoke selectByVisibleText(), selectByValue(), or selectByIndex(). Attempting to click standard <option> tags directly without the Select wrapper often throws ElementNotInteractableException on headless browsers.

Select countryDropdown = new Select(driver.findElement(By.id("country")));
countryDropdown.selectByVisibleText("United States");
Tips to remember
  • Walk through select an option from a standard HTML <select> dropdown as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the select an option from a standard HTML <select> dropdown snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Hard Very Common 1 minQ14 / 80

Q14.How do you automate custom bootstrap or React dropdowns that do not use <select> tags?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Hands-on "how would you automate custom bootstrap or React dropdowns that do not use <select> tags" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Modern UI frameworks build dropdowns using <div>, <ul>, and <li> tags styled with CSS. Attempting to instantiate a Select class on a non-<select> tag throws UnexpectedTagNameException. To automate custom dropdowns, click the trigger element to expand the list, query driver.findElements() for the option list items, and iterate through them to match visible text before clicking.

driver.findElement(By.id("custom-dropdown-trigger")).click();
for (WebElement opt : driver.findElements(By.cssSelector(".dropdown-item"))) {
    if (opt.getText().trim().equals("Enterprise Tier")) { opt.click(); break; }
}
Tips to remember
  • Walk through automate custom bootstrap or React dropdowns that do not use <select> tags as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the automate custom bootstrap or React dropdowns that do not use <select> tags snippet live — panels often ask you to type it, not describe it.
  • Say how you clean up or roll back the data you touch — DB questions are really data-hygiene questions.
Medium Very Common 1 minQ15 / 80

Q15.How do you switch context to handle JavaScript Alerts, Confirmations, and Prompts?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you switch context to handle JavaScript Alerts, Confirmations, and Prompts" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

JavaScript alerts exist outside the HTML DOM; standard locators cannot find alert buttons. To handle alerts, engineers must pause execution until ExpectedConditions.alertIsPresent() resolves, then invoke driver.switchTo().alert(). Once switched, call alert.accept() to click OK, alert.dismiss() to click Cancel, or alert.sendKeys() to input text into prompt dialogues.

Alert alert = wait.until(ExpectedConditions.alertIsPresent());
System.out.println("Alert text: " + alert.getText());
alert.accept();
Tips to remember
  • Walk through switch context to handle JavaScript Alerts, Confirmations, and Prompts as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the switch context to handle JavaScript Alerts, Confirmations, and Prompts snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Medium Very Common 1 minQ16 / 80

Q16.How do you switch into an iframe and safely return to the main document context?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Hands-on "how would you switch into an iframe and safely return to the main document context" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Iframes encapsulate independent HTML documents inside parent frames. Elements inside an iframe throw NoSuchElementException if queried from the parent context. Switch context using driver.switchTo().frame(index | name | WebElement). Once iframe actions conclude, invoke driver.switchTo().defaultContent() to revert focus back to the top-level document structure.

wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("payment-frame")));
driver.findElement(By.id("cvv")).sendKeys("123");
driver.switchTo().defaultContent();
Tips to remember
  • Walk through switch into an iframe and safely return to the main document context as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the switch into an iframe and safely return to the main document context snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Medium Very Common 1 minQ17 / 80

Q17.How do you switch window handles when clicking a link opens an external OAuth tab?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you switch window handles when clicking a link opens an external OAuth tab" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use driver.getWindowHandle() before clicking to record the parent window string ID. After clicking, invoke driver.getWindowHandles() to obtain a Set<String> containing all open window IDs. Iterate through the set and call driver.switchTo().window(handle) when the handle does not match the parent ID.

String parent = driver.getWindowHandle();
driver.findElement(By.id("oauth-login")).click();
for (String h : driver.getWindowHandles()) {
    if (!h.equals(parent)) { driver.switchTo().window(h); break; }
}
Tips to remember
  • Walk through switch window handles when clicking a link opens an external OAuth tab as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the switch window handles when clicking a link opens an external OAuth tab snippet live — panels often ask you to type it, not describe it.
  • Cover token expiry and refresh in your answer; most candidates only describe the happy-path login.
Medium Very Common 1 minQ18 / 80

Q18.Demonstrate how to execute JavaScript using JavascriptExecutor to click obscured elements.

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

This Selenium question checks whether you can go beyond textbook knowledge on Demonstrate how to execute JavaScript using JavascriptExecutor to click obscured elements and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

When sticky navigation bars or modal backdrops obscure target buttons, native driver.click() throws ElementClickInterceptedException. Casting WebDriver to JavascriptExecutor allows injecting direct DOM click instructions (`arguments[0].click()`), bypassing viewport coordinate occlusion entirely.

JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement hiddenBtn = driver.findElement(By.id("submit"));
js.executeScript("arguments[0].click();", hiddenBtn);
Tips to remember
  • Anchor the answer in a real Selenium project — panels reward specificity on Demonstrate how to execute JavaScript using JavascriptExecutor to click obscured elements over textbook wording.
  • Be ready to whiteboard the Demonstrate how to execute JavaScript using JavascriptExecutor to click obscured elements snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Medium Very Common 1 minQ19 / 80

Q19.Demonstrate how to scroll web elements into viewport view using JavascriptExecutor.

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

This Selenium question checks whether you can go beyond textbook knowledge on Demonstrate how to scroll web elements into viewport view using JavascriptExecutor and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

Elements outside the viewport may throw ElementNotInteractableException on Safari or older ChromeDriver versions. Use JavascriptExecutor with `arguments[0].scrollIntoView(true);` to align the top of the element with the top of the viewport prior to interaction.

WebElement footerLink = driver.findElement(By.id("terms"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", footerLink);
footerLink.click();
Tips to remember
  • Anchor the answer in a real Selenium project — panels reward specificity on Demonstrate how to scroll web elements into viewport view using JavascriptExecutor over textbook wording.
  • Be ready to whiteboard the Demonstrate how to scroll web elements into viewport view using JavascriptExecutor snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Medium Very Common 1 minQ20 / 80

Q20.How do you automate complex mouse hover interactions using the Actions class?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you automate complex mouse hover interactions using the Actions class" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Multi-level navigation menus require hovering over parent items before child links render in the DOM. Instantiate org.openqa.selenium.interactions.Actions, chain moveToElement(target), and append .perform() to execute the built composite action chain.

Actions actions = new Actions(driver);
WebElement menu = driver.findElement(By.id("products-menu"));
actions.moveToElement(menu).perform();
wait.until(ExpectedConditions.elementToBeClickable(By.id("cloud-tier"))).click();
Tips to remember
  • Walk through automate complex mouse hover interactions using the Actions class as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the automate complex mouse hover interactions using the Actions class snippet live — panels often ask you to type it, not describe it.
  • Mention capability matrix and cost/queue trade-offs — that's the operational angle panels probe next.
Confidence check

If you can confidently answer the Fresher (0–1 yrs) questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

2. Mid-level (2–4 yrs)

Intermediate Very Common 1 minQ21 / 80

Q21.How do you handle browser notifications/pop-ups in Selenium?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you handle browser notifications/pop-ups" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Browser notification prompts can be handled using ChromeOptions: ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<>(); prefs.put("profile.default_content_setting_values.notifications", 2); options.setExperimentalOption("prefs", prefs);. The value 2 means "block". For geolocation: set "profile.default_content_setting_values.geolocation" to 2. For allowing all notifications on a specific site, you can use Chrome DevTools Protocol (CDP) in Selenium 4: ((HasAuthentication) driver).register(UsernameAndPassword.of("user", "pass"));. For JavaScript alerts within the page, use the Alert interface (covered in later questions).

Tips to remember
  • Walk through handle browser notifications/pop-ups as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle browser notifications/pop-ups snippet live — panels often ask you to type it, not describe it.
  • Cover token expiry and refresh in your answer; most candidates only describe the happy-path login.
Intermediate Very Common 1 minQ22 / 80

Q22.What is a NoSuchElementException and how do you handle it?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Interviewers open with "NoSuchElementException and how do you handle it" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

NoSuchElementException is thrown when findElement() cannot locate an element using the given locator strategy. Common causes: wrong locator, element not yet loaded (synchronization issue), element in a different frame/window, or element dynamically removed. Handling strategies: (1) Add proper waits — explicit wait with ExpectedConditions.presenceOfElementLocated(). (2) Verify the locator — use browser DevTools to validate your XPath/CSS. (3) Check if the element is inside an iframe — switch to the frame first. (4) Check if the element is in a different window. (5) Use findElements() instead and check list size > 0. (6) Wrap in a try-catch or FluentWait with ignored exception. The most common root cause is timing — always use explicit waits.

Tips to remember
  • Open with a one-sentence definition of NoSuchElementException and how do you handle it, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the NoSuchElementException and how do you handle it snippet live — panels often ask you to type it, not describe it.
  • Say explicitly that you prefer CSS/relative locators and only fall back to XPath for text or axes — panels grade locator hygiene here.
Intermediate Very Common 1 minQ23 / 80

Q23.How do you run Chrome in headless mode?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you run Chrome in headless mode" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); WebDriver driver = new ChromeDriver(options); // Or using newer headless: options.addArguments("--headless=new");. The --headless=new` mode (Chrome 112+) is the newer headless implementation that behaves more like the real browser — supports extensions, printing to PDF, and more. Headless mode is commonly used in CI/CD environments where no display is available. Benefits: faster execution, no GUI overhead, works on servers. Limitations: some browser behaviors differ from headed mode (font rendering, screen size). Always run a subset of tests in headed mode before release.

Tips to remember
  • Walk through run Chrome in headless mode as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the run Chrome in headless mode snippet live — panels often ask you to type it, not describe it.
  • Describe the pipeline stage order and what makes the build fail — a vague "we run tests in CI" answer stalls here.
Intermediate Very Common 1 minQ24 / 80

Q24.How do you set browser download directory in Selenium?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Hands-on "how would you set browser download directory" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

For Chrome: Map<String, Object> prefs = new HashMap<>(); prefs.put("download.default_directory", "/path/to/downloads"); prefs.put("download.prompt_for_download", false); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", prefs);. For Firefox: FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", "/path/to/downloads"); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,text/csv"); FirefoxOptions options = new FirefoxOptions(); options.setProfile(profile);. Setting download directory is essential for testing file download functionality.

Tips to remember
  • Walk through set browser download directory as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the set browser download directory snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Intermediate Very Common 1 minQ25 / 80

Q25.How do you switch between browser windows/tabs?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you switch between browser windows/tabs" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use driver.switchTo().window(handle) where handle is the window handle string. Steps: (1) Store the parent window handle: String parentHandle = driver.getWindowHandle();. (2) Perform action that opens a new window. (3) Get all handles: Set<String> allHandles = driver.getWindowHandles();. (4) Switch to the new window by iterating handles and skipping the parent. (5) Perform actions in the new window. (6) Close and switch back: driver.close(); driver.switchTo().window(parentHandle);. In Selenium 4, you can also open a new tab/window without clicking a link: driver.switchTo().newWindow(WindowType.TAB); or driver.switchTo().newWindow(WindowType.WINDOW);.

Tips to remember
  • Walk through switch between browser windows/tabs as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the switch between browser windows/tabs snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Intermediate Very Common 1 minQ26 / 80

Q26.How do you find dynamic elements in Selenium?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Hands-on "how would you find dynamic elements" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Dynamic elements have IDs, classes, or attributes that change on each page load. Strategies: (1) Use stable parent elements and traverse: driver.findElement(By.xpath("//div[@class='stable-container']//button[contains(@class,'submit')]"));. (2) Use contains() in XPath: //button[contains(@id,'submit')]. (3) Use starts-with(): //button[starts-with(@id,'btn_')]. (4) Use CSS selectors with partial matching: [class*='btn-submit']. (5) Use text content: //button[text()='Submit']. (6) Use relative locators (Selenium 4) to find elements near stable elements. (7) Use multiple attribute matching for unique identification.

Tips to remember
  • Walk through find dynamic elements as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the find dynamic elements snippet live — panels often ask you to type it, not describe it.
  • Say explicitly that you prefer CSS/relative locators and only fall back to XPath for text or axes — panels grade locator hygiene here.
Intermediate Very Common 1 minQ27 / 80

Q27.How do you find elements inside an iframe?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you find elements inside an iframe" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

First, switch to the iframe: driver.switchTo().frame("frameId"); or driver.switchTo().frame(frameElement); or driver.switchTo().frame(0); (by index). Then find elements as usual. To return to the main content: driver.switchTo().defaultContent();. To switch to a parent frame: driver.switchTo().parentFrame();. Always switch back after interacting with iframe content. Example: WebElement iframe = driver.findElement(By.cssSelector("iframe[title='Chat']")); driver.switchTo().frame(iframe); driver.findElement(By.id("messageInput")).sendKeys("Hello"); driver.switchTo().defaultContent();.

Tips to remember
  • Walk through find elements inside an iframe as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the find elements inside an iframe snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Intermediate Very Common 1 minQ28 / 80

Q28.What is a stale element reference exception and how to avoid it?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Interviewers open with "stale element reference exception and how to avoid it" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

StaleElementReferenceException occurs when the DOM changes after you locate an element but before you interact with it. Causes: page refresh, JavaScript DOM updates, React/Angular re-renders, AJAX callbacks modifying the DOM. Solutions: (1) Re-find the element every time (don't cache). (2) Use Page Object Model with lazy initialization. (3) Use a retry mechanism: for (int i = 0; i < 3; i++) { try { element.click(); break; } catch (StaleElementReferenceException e) { element = driver.findElement(locator); } }. (4) Use FluentWait with ignored exception types. (5) In Playwright-style thinking, locate fresh each time.

Tips to remember
  • Open with a one-sentence definition of stale element reference exception and how to avoid it, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the stale element reference exception and how to avoid it snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Intermediate Very Common 1 minQ29 / 80

Q29.What are the best practices for writing locators?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Interviewers open with "best practices for writing locators" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

(1) Use data-testid attributes whenever possible — they're stable and decoupled from UI changes. (2) Prefer ID > name > CSS > XPath in priority order. (3) Keep locators short and readable. (4) Avoid absolute XPath paths. (5) Avoid indexing unless the order is guaranteed. (6) Use contains() and starts-with() for dynamic attributes. (7) Combine stable attributes for uniqueness. (8) Avoid XPath text() matching for internationalized apps. (9) Store locators as constants or in Page Objects, not scattered in test methods. (10) Review and refactor locators regularly as the app evolves. (11) Use code review for locator quality. (12) Prefer CSS over XPath for performance.

Tips to remember
  • Open with a one-sentence definition of best practices for writing locators, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the best practices for writing locators snippet live — panels often ask you to type it, not describe it.
  • Say explicitly that you prefer CSS/relative locators and only fall back to XPath for text or axes — panels grade locator hygiene here.
Intermediate Very Common 1 minQ30 / 80

Q30.What are ExpectedConditions in Selenium? List some important ones.

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Interviewers open with "ExpectedConditions in Selenium? List some important ones" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

ExpectedConditions is a utility class in Selenium providing common wait conditions. Important ones: alertIsPresent(), elementToBeClickable(By), elementToBeSelected(By), frameToBeAvailableAndSwitchToIt(By), invisibilityOfElementLocated(By), presenceOfAllElementsLocatedBy(By), presenceOfElementLocated(By), textToBePresentInElementLocated(By, String), titleIs(String), titleContains(String), visibilityOf(WebElement), visibilityOfAllElementsLocatedBy(By), visibilityOfElementLocated(By), numberOfWindowsToBe(int), stalenessOf(WebElement), refreshed(ExpectedCondition) — useful for stale element handling. These cover 90% of synchronization needs in test automation.

Tips to remember
  • Open with a one-sentence definition of ExpectedConditions in Selenium? List some important ones, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the ExpectedConditions in Selenium? List some important ones snippet live — panels often ask you to type it, not describe it.
  • Explain the DOM re-render that causes it and show you re-locate inside the action instead of caching the element.
Intermediate Very Common 1 minQ31 / 80

Q31.How do you upload a file in Selenium?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you upload a file" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

For file input elements: WebElement fileInput = driver.findElement(By.cssSelector("input[type='file']")); fileInput.sendKeys("/absolute/path/to/file.pdf");. This works on the native file input element even if it's hidden (use JavaScript to make it visible if needed). For drag-and-drop upload areas: simulate the file drop using JavaScript: ((JavascriptExecutor) driver).executeScript("var input = document.createElement('input'); input.type = 'file'; input.style.display = 'none'; document.body.appendChild(input);");. For custom upload widgets, you may need to interact with the library-specific API. The sendKeys approach on a file input is the most reliable method.

Tips to remember
  • Walk through upload a file as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the upload a file snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Intermediate Common 1 minQ32 / 80

Q32.What is Page Object Model (POM)?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Interviewers open with "Page Object Model (POM)" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Page Object Model is a design pattern where each web page or component is represented by a class. The class encapsulates: (1) WebElements (using locator strategies). (2) Methods that operate on those elements (login(), search(), addToCart()). (3) Page validation methods. Benefits: reduced code duplication, improved maintenance (UI change → update one class), better readability, and reusability across tests. Example: public class LoginPage { By usernameInput = By.id("username"); By passwordInput = By.id("password"); By loginBtn = By.id("loginBtn"); public void login(String user, String pass) { driver.findElement(usernameInput).sendKeys(user); driver.findElement(passwordInput).sendKeys(pass); driver.findElement(loginBtn).click(); } }.

Tips to remember
  • Open with a one-sentence definition of Page Object Model (POM), then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the Page Object Model (POM) snippet live — panels often ask you to type it, not describe it.
  • Add one sentence on what does NOT belong in a page object (assertions, test data) — that boundary is what separates mid from senior answers.
Intermediate Common 1 minQ33 / 80

Q33.How do you read configuration from properties files?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you read configuration from properties files" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create a ConfigReader class: public class ConfigReader { private static Properties prop = new Properties(); static { try { FileInputStream fis = new FileInputStream("config.properties"); prop.load(fis); } catch (IOException e) { e.printStackTrace(); } } public static String get(String key) { return prop.getProperty(key); } public static String getBrowser() { return prop.getProperty("browser", "chrome"); } public static String getUrl() { return prop.getProperty("url", "https://example.com"); } public static int getTimeout() { return Integer.parseInt(prop.getProperty("timeout", "10")); } }. Config file example: browser=chrome\nurl=https://example.com\ntimeout=10. This separates configuration from code, making tests environment-agnostic.

Tips to remember
  • Walk through read configuration from properties files as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the read configuration from properties files snippet live — panels often ask you to type it, not describe it.
  • Say who reads the report and what decision it drives — evidence-for-humans framing beats a tool name list.
Confidence check

If you can confidently answer the Mid-level (2–4 yrs) questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

3. Senior / SDET (5+ yrs)

Advanced Common 1 minQ34 / 80

Q34.What is the page load strategy in Selenium?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Interviewers open with "page load strategy" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Page load strategy determines when Selenium considers a page fully loaded. Three strategies: (1) NORMAL (default) — waits for the entire page including all resources (images, CSS, JS) to load. Set via: ChromeOptions options = new ChromeOptions(); options.setPageLoadStrategy(PageLoadStrategy.NORMAL);. (2) EAGER — waits only for DOMContentLoaded event (HTML loaded, but resources like images may still load). Faster but may encounter incomplete elements. (3) NONE — doesn't wait for anything after the initial URL is loaded. Use for SPAs that load content via AJAX. Choose EAGER for faster execution when images/styles are not critical, and NONE when using explicit waits for specific elements anyway.

Tips to remember
  • Open with a one-sentence definition of page load strategy, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the page load strategy snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Advanced Common 1 minQ35 / 80

Q35.How do you emulate mobile devices in Chrome?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you emulate mobile devices in Chrome" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use Chrome's device emulation: Map<String, Object> deviceMetrics = new HashMap<>(); deviceMetrics.put("width", 375); deviceMetrics.put("height", 812); deviceMetrics.put("pixelRatio", 3.0); Map<String, Object> mobileEmulation = new HashMap<>(); mobileEmulation.put("deviceMetrics", deviceMetrics); mobileEmulation.put("userAgent", "Mozilla/5.0 (iPhone...)"); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("mobileEmulation", mobileEmulation);. For predefined devices: mobileEmulation.put("deviceName", "iPhone X");. This is crucial for responsive design testing and mobile-specific UI verification without actual mobile devices.

Tips to remember
  • Walk through emulate mobile devices in Chrome as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the emulate mobile devices in Chrome snippet live — panels often ask you to type it, not describe it.
  • Split the answer into emulator (fast feedback) vs real device (final gate) and say where each runs in your pipeline.
Advanced Common 1 minQ36 / 80

Q36.How do you pass capabilities to RemoteWebDriver?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you pass capabilities to RemoteWebDriver" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use DesiredCapabilities or browser-specific options: ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); options.setCapability("browserVersion", "120"); options.setCapability("platformName", "Windows 11"); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444"), options);. For cloud providers: options.setCapability("browserstack.user", "username"); options.setCapability("browserstack.key", "accesskey"); options.setCapability("project", "My Project"); options.setCapability("build", "Test Build 1");. Capabilities tell the remote server what browser, version, OS, and features you need.

Tips to remember
  • Walk through pass capabilities to RemoteWebDriver as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the pass capabilities to RemoteWebDriver snippet live — panels often ask you to type it, not describe it.
  • Mention capability matrix and cost/queue trade-offs — that's the operational angle panels probe next.
Advanced Common 1 minQ37 / 80

Q37.How do you handle Angular elements in Selenium?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you handle Angular elements" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Angular apps use dynamic attribute bindings. Strategies: (1) Use Angular-specific attributes: //button[@_ngcontent-c123]. (2) Use contains(@class, 'mat-') for Material Design components. (3) Use CSS selectors with [ng-reflect-*] attributes: [ng-reflect-name='username']. (4) For Angular Material: //mat-select for dropdowns, //mat-checkbox for checkboxes. (5) Wait for Angular stability: ((JavascriptExecutor) driver).executeScript("return window.getAllAngularTestabilities().filter(t => !t.isStable());");. Angular elements often have extra overlay layers, so use JavaScript click if normal click fails.

Tips to remember
  • Walk through handle Angular elements as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle Angular elements snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Common 1 minQ38 / 80

Q38.How do you create a custom ExpectedCondition?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Hands-on "how would you create a custom ExpectedCondition" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Implement the ExpectedCondition interface: WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); wait.until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { WebElement el = d.findElement(By.id("progress")); String width = el.getCssValue("width"); return "100%".equals(width) || "0px".equals(width); } });. Or use lambda: wait.until(d -> { WebElement el = d.findElement(By.id("progress")); return "100%".equals(el.getCssValue("width")); });. Custom conditions are useful for application-specific behaviors like waiting for animations to complete, progress bars to fill, or custom JavaScript states.

Tips to remember
  • Walk through create a custom ExpectedCondition as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the create a custom ExpectedCondition snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Common 1 minQ39 / 80

Q39.How do you handle dynamic wait times based on element behavior?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you handle dynamic wait times based on element behavior" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use a polling approach with FluentWait: Wait<WebDriver> wait = new FluentWait<>(driver) .withTimeout(Duration.ofSeconds(30)) .pollingEvery(Duration.ofMillis(200)) .ignoring(NoSuchElementException.class).ignoring(StaleElementReferenceException.class); // Wait until element is stable (same content for 2 consecutive polls) wait.until(d -> { WebElement el = d.findElement(By.id("dynamic-content")); String text1 = el.getText(); sleep(200); String text2 = d.findElement(By.id("dynamic-content")).getText(); return text1.equals(text2) && !text1.isEmpty(); });. This pattern waits until dynamic content stabilizes — useful for auto-refreshing dashboards, live data feeds, or multi-step AJAX updates.

Tips to remember
  • Walk through handle dynamic wait times based on element behavior as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle dynamic wait times based on element behavior snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Advanced Common 1 minQ40 / 80

Q40.What is the best practice for combining waits in a test framework?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Interviewers open with "best practice for combining waits in a test framework" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

(1) Define a set of reusable wait utility methods in a base class or helper: public void waitForElementVisible(WebElement element, int timeout), public void waitForElementClickable(By locator, int timeout), etc. (2) Use a standard timeout constant (e.g., 10 seconds) with per-method overrides. (3) Implement retry mechanisms for flaky operations. (4) Log wait operations and failures for debugging. (5) Use ExpectedConditions.or() and ExpectedConditions.and() for complex conditions. (6) Avoid Thread.sleep completely. (7) Use a wait timeout equal to the maximum expected load time plus a buffer. (8) Take screenshots on TimeoutException for diagnostics.

Tips to remember
  • Open with a one-sentence definition of best practice for combining waits in a test framework, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the best practice for combining waits in a test framework snippet live — panels often ask you to type it, not describe it.
  • Quote a real flake-rate number before and after your fix; measured outcomes score far higher than "we added retries".
Advanced Common 1 minQ41 / 80

Q41.How do you handle timeouts in Selenium tests gracefully?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you handle timeouts in Selenium tests gracefully" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Use try-catch around wait operations: try { wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("element"))); } catch (TimeoutException e) { // Log the failure, take screenshot, but don't throw // Continue with fallback or mark test as warning File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); // log attachment }. (2) Implement a soft assertion library that collects failures without stopping the test. (3) Use test retries at the framework level (TestNG IRetryAnalyzer). (4) Log detailed timing information for debugging. (5) Differentiate between critical and non-critical elements — non-critical failures can be logged without failing the test.

Tips to remember
  • Walk through handle timeouts in Selenium tests gracefully as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle timeouts in Selenium tests gracefully snippet live — panels often ask you to type it, not describe it.
  • Say who reads the report and what decision it drives — evidence-for-humans framing beats a tool name list.
Advanced Common 1 minQ42 / 80

Q42.How do you handle unexpected alerts in Selenium?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Hands-on "how would you handle unexpected alerts" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use ExpectedConditions.alertIsPresent() with a short timeout to check for unexpected alerts: try { WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(2)); wait.until(ExpectedConditions.alertIsPresent()); driver.switchTo().alert().accept(); } catch (TimeoutException e) { // No alert present — continue }. For catching alerts that appear during actions, you can also set ChromeOptions to dismiss alerts automatically: options.setCapability("unexpectedAlertBehaviour", "dismiss");. Unexpected alerts often occur from JavaScript errors, form validation popups, or session timeout warnings.

Tips to remember
  • Walk through handle unexpected alerts as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle unexpected alerts snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Common 1 minQ43 / 80

Q43.How do you handle nested iframes?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you handle nested iframes" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Switch step by step through each level: driver.switchTo().frame("outer-frame"); // enters outer iframe driver.switchTo().frame("inner-frame"); // enters inner iframe // interact with inner iframe content driver.switchTo().parentFrame(); // back to outer iframe driver.switchTo().defaultContent(); // back to main page. You can also switch directly using the iframe's WebElement: WebElement outerFrame = driver.findElement(By.cssSelector("iframe#outer")); WebElement innerFrame = outerFrame.findElement(By.cssSelector("iframe#inner"));. Nested iframes are common in complex applications like payment gateways, document editors, and legacy enterprise portals.

Tips to remember
  • Walk through handle nested iframes as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle nested iframes snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Advanced Common 1 minQ44 / 80

Q44.How do you find elements inside an iframe without switching?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you find elements inside an iframe without switching" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

You can't directly interact with iframe elements without switching to the iframe context. However, you can use JavaScript: ((JavascriptExecutor) driver).executeScript("return document.querySelector('#outer-iframe').contentDocument.querySelector('#inner-element').innerText;");. This accesses the iframe's contentDocument. For reading values only (not interaction), this can be more efficient. But for click(), sendKeys(), and other actions, you must switch to the iframe. Selenium's WebDriver design requires switching because element interaction commands are scoped to the current browsing context.

Tips to remember
  • Walk through find elements inside an iframe without switching as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the find elements inside an iframe without switching snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Advanced Common 1 minQ45 / 80

Q45.How do you handle the Windows authentication popup?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you handle the Windows authentication popup" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

The Windows authentication popup (native OS dialog) cannot be handled by Selenium directly. Solutions: (1) Use URL-embedded credentials: driver.get("https://username:password@example.com");. (2) Use AutoIT (Windows only) to handle the native dialog. (3) Use Robot class (Java): Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_U); // type username.... (4) For Selenium 4, use CDP-based authentication: ((HasAuthentication) driver).register(UsernameAndPassword.of("user", "pass"));. (5) Configure the browser to trust the site or auto-authenticate. Option 1 is simplest; option 4 is the most robust for modern setups.

Tips to remember
  • Walk through handle the Windows authentication popup as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle the Windows authentication popup snippet live — panels often ask you to type it, not describe it.
  • Cover token expiry and refresh in your answer; most candidates only describe the happy-path login.
Advanced Common 1 minQ46 / 80

Q46.How do you handle browser download popups?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Hands-on "how would you handle browser download popups" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Pre-configure the browser to auto-download without prompting: For Chrome: Map<String, Object> prefs = new HashMap<>(); prefs.put("download.prompt_for_download", false); prefs.put("download.directory_upgrade", true); prefs.put("safebrowsing.enabled", true); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", prefs);. For Firefox: FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,text/csv,application/zip"); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", "/path/to/downloads");. This disables the "Save As" dialog and downloads files automatically to the specified directory.

Tips to remember
  • Walk through handle browser download popups as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle browser download popups snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Common 1 minQ47 / 80

Q47.How do you handle HTML5 drag and drop in Selenium?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you handle HTML5 drag and drop" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

HTML5 drag-and-drop doesn't always work with Selenium's Actions class because browsers implement it differently. Workarounds: (1) Use JavaScript to simulate HTML5 drag-and-drop events. (2) Use the html5-drag-and-drop polyfill library. (3) Bypass the drag-and-drop entirely — directly manipulate the data model if possible. JavaScript approach: ((JavascriptExecutor) driver).executeScript("var src=arguments[0],tgt=arguments[1]; var dt=new DataTransfer(); src.dispatchEvent(new DragEvent('dragstart',{dataTransfer:dt})); tgt.dispatchEvent(new DragEvent('drop',{dataTransfer:dt})); src.dispatchEvent(new DragEvent('dragend',{dataTransfer:dt}));", sourceElement, targetElement);. This fires all the necessary HTML5 drag events.

Tips to remember
  • Walk through handle HTML5 drag and drop as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle HTML5 drag and drop snippet live — panels often ask you to type it, not describe it.
  • Explain how you test asynchronous flows (polling, consumer assertions, timeouts) rather than treating it as a sync call.
Advanced Common 1 minQ48 / 80

Q48.How do you interact with a rich text editor (WYSIWYG) in Selenium?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Hands-on "how would you interact with a rich text editor (WYSIWYG)" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Rich text editors (TinyMCE, CKEditor, Quill) use iframes or contentEditable divs. For iframe-based editors: driver.switchTo().frame(editorIframe); driver.findElement(By.tagName("body")).sendKeys("Hello World");. For contentEditable divs: WebElement editor = driver.findElement(By.cssSelector("[contenteditable='true']")); editor.sendKeys("Hello World");. To clear: editor.clear(); or editor.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE);. For advanced formatting (bold, italic), use keyboard shortcuts: editor.sendKeys(Keys.chord(Keys.CONTROL, "b")); then type text. For setting HTML content: use JavaScript: ((JavascriptExecutor) driver).executeScript("arguments[0].innerHTML = arguments[1];", editor, "<p>Formatted <b>text</b></p>");.

Tips to remember
  • Walk through interact with a rich text editor (WYSIWYG) as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the interact with a rich text editor (WYSIWYG) snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Advanced Common 1 minQ49 / 80

Q49.How do you handle file download in Selenium?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you handle file download" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Click the download button/link. (2) Wait for the file to appear in the download directory: Path downloadPath = Paths.get("/path/to/downloads"); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30)); wait.until(d -> { File dir = downloadPath.toFile(); File[] files = dir.listFiles((f, name) -> name.startsWith("report")); return files != null && files.length > 0; });. (3) Verify the downloaded file: File downloadedFile = downloadPath.toFile().listFiles()[0]; Assert.assertTrue(downloadedFile.length() > 0);. (4) Clean up: downloadedFile.delete();. For dynamic filenames, use Files.list(downloadPath) and find files by last modified time or name pattern.

Tips to remember
  • Walk through handle file download as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle file download snippet live — panels often ask you to type it, not describe it.
  • Say who reads the report and what decision it drives — evidence-for-humans framing beats a tool name list.
Advanced Common 1 minQ50 / 80

Q50.How do you perform multiple actions in sequence using Actions class?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Hands-on "how would you perform multiple actions in sequence using Actions class" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Chain action methods and call perform() once: Actions actions = new Actions(driver); actions.moveToElement(userMenu) .pause(Duration.ofMillis(300)) .click() .pause(Duration.ofMillis(200)) .sendKeys("admin") .pause(Duration.ofMillis(100)) .sendKeys(Keys.TAB) .pause(Duration.ofMillis(100)) .sendKeys("password123") .sendKeys(Keys.ENTER) .perform();. This builds a composite action that executes in order. Each action is queued in the browser's event queue. You can also build and perform actions separately: actions.moveToElement(element).perform(); // execute first action actions.click().perform(); // execute second action. The builder pattern allows either chained or step-by-step execution.

Tips to remember
  • Walk through perform multiple actions in sequence using Actions class as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the perform multiple actions in sequence using Actions class snippet live — panels often ask you to type it, not describe it.
  • Explain how you test asynchronous flows (polling, consumer assertions, timeouts) rather than treating it as a sync call.
Advanced Common 1 minQ51 / 80

Q51.How do you handle driver initialization in a framework?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you handle driver initialization in a framework" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create a DriverFactory class: public class DriverFactory { private static ThreadLocal<WebDriver> driver = new ThreadLocal<>(); public static WebDriver getDriver() { return driver.get(); } public static void setDriver(String browser) { switch(browser) { case "chrome": driver.set(new ChromeDriver(chromeOptions())); break; case "firefox": driver.set(new FirefoxDriver(firefoxOptions())); break; } getDriver().manage().window().maximize(); getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); } public static void quitDriver() { getDriver().quit(); driver.remove(); } }. Call DriverFactory.setDriver("chrome") in @BeforeMethod and DriverFactory.quitDriver() in @AfterMethod. This centralizes driver creation and supports easy browser switching and parallel execution.

Tips to remember
  • Walk through handle driver initialization in a framework as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle driver initialization in a framework snippet live — panels often ask you to type it, not describe it.
  • Call out test isolation and shared-state risk (data, sessions, ports) before you talk about worker counts.
Advanced Common 1 minQ52 / 80

Q52.How do you take screenshots on test failure?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you take screenshots on test failure" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Implement ITestListener: public class TestListener implements ITestListener { @Override public void onTestFailure(ITestResult result) { Object driver = result.getTestContext().getAttribute("driver"); if (driver != null) { String screenshotPath = takeScreenshot((WebDriver) driver, result.getName()); result.setAttribute("screenshot", screenshotPath); } } private String takeScreenshot(WebDriver driver, String testName) { String path = "screenshots/" + testName + "_" + System.currentTimeMillis() + ".png"; File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(src, new File(path)); return path; } }. Register in testng.xml: <listeners><listener class-name="com.test.TestListener"/></listeners>. Screenshots provide visual evidence for failure analysis.

Tips to remember
  • Walk through take screenshots on test failure as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the take screenshots on test failure snippet live — panels often ask you to type it, not describe it.
  • Say who reads the report and what decision it drives — evidence-for-humans framing beats a tool name list.
Advanced Common 1 minQ53 / 80

Q53.How do you handle test data with Excel files?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you handle test data with Excel files" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use Apache POI library: public Object[][] getExcelData(String filePath, String sheetName) { FileInputStream fis = new FileInputStream(filePath); Workbook workbook = new XSSFWorkbook(fis); Sheet sheet = workbook.getSheet(sheetName); int rows = sheet.getPhysicalNumberOfRows(); int cols = sheet.getRow(0).getPhysicalNumberOfCells(); Object[][] data = new Object[rows-1][cols]; for (int i = 1; i < rows; i++) { for (int j = 0; j < cols; j++) { data[i-1][j] = sheet.getRow(i).getCell(j).toString(); } } return data; }. Use with DataProvider: @DataProvider(name = "excelData") public Object[][] getData() { return getExcelData("testdata/login.xlsx", "Sheet1"); }. Excel is popular for non-technical team members to maintain test data without touching code.

Tips to remember
  • Walk through handle test data with Excel files as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle test data with Excel files snippet live — panels often ask you to type it, not describe it.
  • Reference the specific OWASP category and the check you automate for it, not "we do security testing".
Advanced Common 1 minQ54 / 80

Q54.How do you set up Selenium Grid 4?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Hands-on "how would you set up Selenium Grid 4" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Download Selenium Grid 4 jar from selenium.dev. (2) Start Hub/Router: java -jar selenium-server-4.27.0.jar hub (Grid 3) or java -jar selenium-server-4.27.0.jar standalone (Grid 4 single node, simpler). (3) For multi-node: Start Hub first: java -jar selenium-server-4.27.0.jar hub. Then register Nodes: java -jar selenium-server-4.27.0.jar node --hub http://localhost:4444. (4) For Grid 4 fully distributed: java -jar selenium-server-4.27.0.jar eventbus, sessions, sessionmap, distributor, router, node — each in separate processes. (5) Access Grid console at http://localhost:4444. (6) Connect tests: WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444"), new ChromeOptions());.

Tips to remember
  • Walk through set up Selenium Grid 4 as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the set up Selenium Grid 4 snippet live — panels often ask you to type it, not describe it.
  • Mention capability matrix and cost/queue trade-offs — that's the operational angle panels probe next.
Advanced Common 1 minQ55 / 80

Q55.How do you configure Selenium Grid in Docker?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you configure Selenium Grid in Docker" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Use official Selenium Docker images: docker network create grid then docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.27.0 and docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub --shm-size=2gb selenium/node-chrome:4.27.0. For Docker Compose: version: '3' services: chrome: image: selenium/node-chrome:4.27.0 shm_size: 2gb depends_on: - selenium-hub environment: - SE_EVENT_BUS_HOST=selenium-hub - SE_EVENT_BUS_PUBLISH_PORT=4442 - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 selenium-hub: image: selenium/hub:4.27.0 ports: - "4442:4442" - "4443:4443" - "4444:4444". Docker simplifies Grid setup by eliminating manual configuration.

Tips to remember
  • Walk through configure Selenium Grid in Docker as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the configure Selenium Grid in Docker snippet live — panels often ask you to type it, not describe it.
  • Mention pinned browser images and cleanup of containers between runs — panels look for CI cost awareness.
Advanced Common 1 minQ56 / 80

Q56.How do you run parallel tests on Selenium Grid?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Hands-on "how would you run parallel tests on Selenium Grid" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

In testng.xml: <suite name="Suite" parallel="methods" thread-count="5"> <test name="CrossBrowser"> <parameter name="browser" value="chrome"/> <classes> <class name="com.test.LoginTest"/> </classes> </test> </suite>. Create a RemoteWebDriver in your setup: public void setup(String browser) { ChromeOptions options = new ChromeOptions(); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444"), options); }. The Grid Hub distributes test methods across available Nodes. Set thread-count to match total available Node slots. Each test method gets routed to a Node matching its capabilities.

Tips to remember
  • Walk through run parallel tests on Selenium Grid as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the run parallel tests on Selenium Grid snippet live — panels often ask you to type it, not describe it.
  • Call out test isolation and shared-state risk (data, sessions, ports) before you talk about worker counts.
Advanced Common 1 minQ57 / 80

Q57.How do you set up cross-browser testing with Grid?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you set up cross-browser testing with Grid" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create a parameterized test: @Test @Parameters("browser") public void testCrossBrowser(String browser) { WebDriver driver; switch(browser) { case "chrome": driver = new RemoteWebDriver(new URL("http://localhost:4444"), new ChromeOptions()); break; case "firefox": driver = new RemoteWebDriver(new URL("http://localhost:4444"), new FirefoxOptions()); break; case "edge": driver = new RemoteWebDriver(new URL("http://localhost:4444"), new EdgeOptions()); break; } }. In testng.xml, define multiple test tags with different browser parameters. The Grid Hub routes each test to a Node with the requested browser. This enables running the same tests across Chrome, Firefox, and Edge simultaneously.

Tips to remember
  • Walk through set up cross-browser testing with Grid as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the set up cross-browser testing with Grid snippet live — panels often ask you to type it, not describe it.
  • Mention capability matrix and cost/queue trade-offs — that's the operational angle panels probe next.
Advanced Common 1 minQ58 / 80

Q58.How do you use Selenium Grid with cloud providers (BrowserStack/Sauce Labs)?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Hands-on "how would you use Selenium Grid with cloud providers (BrowserStack/Sauce Labs)" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create RemoteWebDriver with cloud provider URL: ChromeOptions options = new ChromeOptions(); options.setCapability("browserstack.user", "YOUR_USERNAME"); options.setCapability("browserstack.key", "YOUR_ACCESS_KEY"); options.setCapability("project", "Selenium Tests"); options.setCapability("build", "Build 1.0"); options.setCapability("name", "Login Test"); WebDriver driver = new RemoteWebDriver(new URL("https://hub-cloud.browserstack.com/wd/hub"), options);. For Sauce Labs: URL("https://YOUR_USERNAME:YOUR_ACCESS_KEY@ondemand.us-west-1.saucelabs.com:443/wd/hub"). Cloud platforms provide instant access to hundreds of browser/OS combinations, video recording, and debugging tools without maintaining your own Grid.

Tips to remember
  • Walk through use Selenium Grid with cloud providers (BrowserStack/Sauce Labs) as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the use Selenium Grid with cloud providers (BrowserStack/Sauce Labs) snippet live — panels often ask you to type it, not describe it.
  • Mention capability matrix and cost/queue trade-offs — that's the operational angle panels probe next.
Advanced Common 1 minQ59 / 80

Q59.How do you capture network traffic using CDP in Selenium 4?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you capture network traffic using CDP in Selenium 4" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

DevTools devTools = ((HasDevTools) driver).getDevTools(); devTools.createSession(); devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); List<Network.RequestWillBeSent> requestList = new ArrayList<>(); devTools.addListener(Network.requestWillBeSent(), request -> { requestList.add(request); System.out.println("URL: " + request.getRequest().getUrl() + " Method: " + request.getRequest().getMethod()); }); // Perform actions that trigger network calls // Later, assert: Assert.assertTrue(requestList.stream().anyMatch(r -> r.getRequest().getUrl().contains("api/data")));. This enables testing API calls, analytics pings, resource loading, and network performance.

Tips to remember
  • Walk through capture network traffic using CDP in Selenium 4 as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the capture network traffic using CDP in Selenium 4 snippet live — panels often ask you to type it, not describe it.
  • Use percentiles (P90/P95) and a concrete SLA rather than averages — averages hide the failures interviewers care about.
Advanced Occasional 1 minQ60 / 80

Q60.How do you mock network responses using CDP?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you mock network responses using CDP" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

DevTools devTools = ((HasDevTools) driver).getDevTools(); devTools.createSession(); devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); devTools.addListener(Network.requestWillBeSent(), request -> { if (request.getRequest().getUrl().contains("api/users")) { Map<String, Object> mockResponse = new HashMap<>(); mockResponse.put("name", "Mock User"); mockResponse.put("email", "mock@test.com"); devTools.send(Fetch.fulfillRequest(request.getRequestId(), 200, "application/json", new Gson().toJson(mockResponse))); } });. This intercepts and responds to network requests with custom data, enabling front-end testing without real backend dependencies.

Tips to remember
  • Walk through mock network responses using CDP as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the mock network responses using CDP snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Advanced Occasional 1 minQ61 / 80

Q61.How do you intercept console logs using CDP?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you intercept console logs using CDP" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

DevTools devTools = ((HasDevTools) driver).getDevTools(); devTools.createSession(); devTools.send(Log.enable()); List<LogEntry> logEntries = new ArrayList<>(); devTools.addListener(Log.entryAdded(), logEntry -> { logEntries.add(logEntry); System.out.println("Log: " + logEntry.getText() + " Level: " + logEntry.getLevel()); }); // Perform actions // Assert log contains expected message: Assert.assertTrue(logEntries.stream().anyMatch(log -> log.getText().contains("App initialized")));. This is invaluable for debugging JavaScript errors, checking console warnings, and verifying application logging without manual DevTools inspection.

Tips to remember
  • Walk through intercept console logs using CDP as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the intercept console logs using CDP snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Advanced Occasional 1 minQ62 / 80

Q62.How do you use device emulation with CDP?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Hands-on "how would you use device emulation with CDP" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

DevTools devTools = ((HasDevTools) driver).getDevTools(); devTools.createSession(); Map<String, Object> metrics = new HashMap<>(); metrics.put("width", 375); metrics.put("height", 812); metrics.put("deviceScaleFactor", 3); metrics.put("mobile", true); devTools.send(Emulation.setDeviceMetricsOverride(375, 812, 3.0, false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty())); // Simulate mobile user agent String userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15"; devTools.send(Network.setUserAgentOverride(userAgent, Optional.empty(), Optional.empty(), Optional.empty()));. CDP emulation is more accurate than ChromeOptions device emulation.

Tips to remember
  • Walk through use device emulation with CDP as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the use device emulation with CDP snippet live — panels often ask you to type it, not describe it.
  • Split the answer into emulator (fast feedback) vs real device (final gate) and say where each runs in your pipeline.
Advanced Occasional 1 minQ63 / 80

Q63.How do you get browser network conditions in Selenium 4?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you get browser network conditions in Selenium 4" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

DevTools devTools = ((HasDevTools) driver).getDevTools(); devTools.createSession(); devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); // Listen for response received events List<Network.ResponseReceived> responses = new ArrayList<>(); devTools.addListener(Network.responseReceived(), response -> { responses.add(response); System.out.println("URL: " + response.getResponse().getUrl() + " Status: " + response.getResponse().getStatus() + " Time: " + response.getResponse().getTiming().getDuration()); });. This provides detailed timing information: DNS lookup, TCP connection, SSL handshake, TTFB, content download. Useful for performance testing and identifying slow API calls.

Tips to remember
  • Walk through get browser network conditions in Selenium 4 as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the get browser network conditions in Selenium 4 snippet live — panels often ask you to type it, not describe it.
  • Use percentiles (P90/P95) and a concrete SLA rather than averages — averages hide the failures interviewers care about.
Advanced Occasional 1 minQ64 / 80

Q64.How do you run Selenium tests in GitHub Actions?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Hands-on "how would you run Selenium tests in GitHub Actions" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create .github/workflows/selenium-tests.yml: name: Selenium Tests on: push: branches: [main] pull_request: branches: [main] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - name: Set up Chrome uses: browser-actions/setup-chrome@v1 - name: Run tests run: mvn clean test -Dbrowser=chrome - name: Upload screenshots if: failure() uses: actions/upload-artifact@v4 with: name: screenshots path: screenshots/. GitHub Actions provides free runners with Chrome pre-installed. Use services like BrowserStack for cross-browser testing on their servers.

Tips to remember
  • Walk through run Selenium tests in GitHub Actions as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the run Selenium tests in GitHub Actions snippet live — panels often ask you to type it, not describe it.
  • Describe the pipeline stage order and what makes the build fail — a vague "we run tests in CI" answer stalls here.
Advanced Occasional 1 minQ65 / 80

Q65.How do you handle dynamic Angular/React elements in Selenium?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you handle dynamic Angular/React elements" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Wait for Angular stability: wait.until(d -> ((JavascriptExecutor)d).executeScript("return window.getAllAngularTestabilities().filter(t => !t.isStable()).length === 0"));. (2) For React, wait for component state: use data-testid attributes. (3) Handle dynamic class names with contains(@class,'component-name'). (4) Wait for animations: use ExpectedConditions with CSS property checks. (5) Use FluentWait with custom ExpectedConditions for framework-specific events. (6) Use JavaScript to check if the component is fully rendered: return document.querySelector('app-root')?.innerHTML?.length > 0. (7) Avoid fragile locators based on auto-generated class names.

Tips to remember
  • Walk through handle dynamic Angular/React elements as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle dynamic Angular/React elements snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Advanced Occasional 1 minQ66 / 80

Q66.How do you test form validation?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Hands-on "how would you test form validation" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Submit form with empty required fields — verify error messages: submitBtn.click(); String error = driver.findElement(By.cssSelector(".field-error")).getText(); Assert.assertEquals("This field is required", error);. (2) Test invalid email formats, minimum/maximum length, pattern mismatches. (3) Test valid data submission — verify success message or navigation. (4) Test form field restrictions (character limits, allowed characters). (5) Test cross-field validation (password + confirm password match). (6) Test server-side validation by manipulating HTTP requests (CDP network interception). (7) Test validation on blur vs on submit.

Tips to remember
  • Walk through test form validation as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the test form validation snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Advanced Occasional 1 minQ67 / 80

Q67.How do you test WebSockets in Selenium?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you test WebSockets" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Use CDP to monitor WebSocket events: devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty())); devTools.addListener(Network.webSocketCreated(), ws -> { System.out.println("WebSocket created: " + ws.getUrl()); }); devTools.addListener(Network.webSocketFrameSent(), frame -> { System.out.println("Sent: " + frame.getResponse().getPayloadData()); }); devTools.addListener(Network.webSocketFrameReceived(), frame -> { System.out.println("Received: " + frame.getResponse().getPayloadData()); });. (2) Perform actions that trigger WebSocket communication. (3) Verify messages sent/received match expected data. (4) Test WebSocket reconnection by throttling network (CDP).

Tips to remember
  • Walk through test WebSockets as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the test WebSockets snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Advanced Occasional 1 minQ68 / 80

Q68.How do you test performance with Selenium?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Hands-on "how would you test performance with Selenium" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

(1) Use Navigation Timing API: Map<String, Object> timing = (Map<String, Object>) js.executeScript("var t = performance.timing; return {loadTime: t.loadEventEnd - t.navigationStart, domReady: t.domComplete - t.domLoading, ttfb: t.responseStart - t.requestStart};");. (2) Use CDP Performance metrics: devTools.send(Performance.enable(Optional.empty())); devTools.addListener(Performance.metrics(), metrics -> { metrics.getMetrics().forEach(m -> System.out.println(m.getName() + ": " + m.getValue())); });. (3) Set performance budgets: Assert.assertTrue((long) timing.get("loadTime") < 3000); // page should load in < 3s. (4) Test under network throttling. (5) Test with multiple iterations for statistical significance.

Tips to remember
  • Walk through test performance with Selenium as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the test performance with Selenium snippet live — panels often ask you to type it, not describe it.
  • Use percentiles (P90/P95) and a concrete SLA rather than averages — averages hide the failures interviewers care about.
Advanced Occasional 1 minQ69 / 80

Q69.How do you implement logging with Log4j in Selenium?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Hands-on "how would you implement logging with Log4j" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Add log4j2 dependency to pom.xml. Create log4j2.xml in resources: <Configuration> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </Console> <File name="File" fileName="logs/selenium-tests.log"> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </File> </Appenders> <Loggers> <Root level="info"> <AppenderRef ref="Console"/> <AppenderRef ref="File"/> </Root> </Loggers> </Configuration>. In test classes: private static final Logger log = LogManager.getLogger(LoginTest.class); log.info("Navigating to login page"); log.error("Login failed", exception);. Structured logging helps in debugging failures.

Tips to remember
  • Walk through implement logging with Log4j as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the implement logging with Log4j snippet live — panels often ask you to type it, not describe it.
  • Add one sentence on what does NOT belong in a page object (assertions, test data) — that boundary is what separates mid from senior answers.
Advanced Occasional 1 minQ70 / 80

Q70.How do you implement step-by-step logging in tests?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Hands-on "how would you implement step-by-step logging in tests" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create a logging utility: public class TestLogger { private static final Logger log = LogManager.getLogger("Test"); private static ExtentTest extentTest; public static void logStep(String step) { log.info("STEP: " + step); if (extentTest != null) extentTest.log(Status.INFO, step); } public static void logPass(String msg) { log.info("PASS: " + msg); if (extentTest != null) extentTest.log(Status.PASS, msg); } public static void logFail(String msg) { log.error("FAIL: " + msg); if (extentTest != null) extentTest.log(Status.FAIL, msg); } }. Use in tests: TestLogger.logStep("Entering username"); loginPage.enterUsername("user"); TestLogger.logPass("Username entered");. This creates a readable step-by-step report for each test.

Tips to remember
  • Walk through implement step-by-step logging in tests as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the implement step-by-step logging in tests snippet live — panels often ask you to type it, not describe it.
  • Say who reads the report and what decision it drives — evidence-for-humans framing beats a tool name list.
Advanced Occasional 1 minQ71 / 80

Q71.How do you use listener pattern in Selenium?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Hands-on "how would you use listener pattern" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Implement WebDriver EventListener: public class MyListener implements WebDriverEventListener { @Override public void beforeClickOn(WebElement element, WebDriver driver) { System.out.println("Clicking on: " + element.getText()); } @Override public void afterClickOn(WebElement element, WebDriver driver) { System.out.println("Clicked successfully"); } @Override public void onException(Throwable throwable, WebDriver driver) { System.out.println("Exception: " + throwable.getMessage()); } }. Register with EventFiringWebDriver: EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver); eventDriver.register(new MyListener());. This provides visibility into all WebDriver operations, useful for logging and debugging.

Tips to remember
  • Walk through use listener pattern as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the use listener pattern snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Occasional 1 minQ72 / 80

Q72.How do you implement conditional wait logic based on element state?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Hands-on "how would you implement conditional wait logic based on element state" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Create a utility that waits differently based on context: public class WaitHelper { public static void waitForElement(WebDriver driver, By locator, WaitCondition condition) { WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); switch(condition) { case PRESENT: wait.until(ExpectedConditions.presenceOfElementLocated(locator)); break; case VISIBLE: wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); break; case CLICKABLE: wait.until(ExpectedConditions.elementToBeClickable(locator)); break; case INVISIBLE: wait.until(ExpectedConditions.invisibilityOfElementLocated(locator)); break; case STALE: wait.until(ExpectedConditions.stalenessOf(driver.findElement(locator))); break; } } }. This provides a clean API for different wait conditions.

Tips to remember
  • Walk through implement conditional wait logic based on element state as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the implement conditional wait logic based on element state snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Occasional 1 minQ73 / 80

Q73.How do you implement test environment validation?

Asked byInfosysWiproCapgeminiTCS
Why interviewers ask this

Hands-on "how would you implement test environment validation" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Before running tests, validate the environment: @BeforeSuite public void validateEnvironment() { // Check browser availability try { WebDriver driver = new ChromeDriver(); driver.quit(); } catch (Exception e) { throw new SkipException("Chrome not available: " + e.getMessage()); } // Check application availability try { URL url = new URL(config.getUrl()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.connect(); Assert.assertEquals(200, conn.getResponseCode()); } catch (Exception e) { throw new SkipException("Application not reachable: " + e.getMessage()); } // Check required files for (String file : config.getRequiredFiles()) { Assert.assertTrue(new File(file).exists(), "Required file not found: " + file); } }. This prevents running tests against a broken environment.

Tips to remember
  • Walk through implement test environment validation as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the implement test environment validation snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Confidence check

If you can confidently answer the Senior / SDET (5+ yrs) questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

4. Selenium Fundamentals

Beginner Occasional 1 minQ74 / 80

Q74.What is WebDriverManager?

Asked byIBMInfosysWiproCapgemini
Why interviewers ask this

Interviewers open with "WebDriverManager" to confirm you can define the concept in one crisp line before going deeper. In Selenium rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

WebDriverManager (by Boni García) is a Java library that automates the management of browser drivers. It automatically detects the installed browser version, downloads the matching driver binary from the official repository, caches it locally, and sets the system property. Usage: WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver();. It supports Chrome, Firefox, Edge, Opera, and PhantomJS. It also supports Docker-based browser execution and can download drivers for specific versions. Selenium 4 introduced Selenium Manager as a built-in alternative, but WebDriverManager remains popular for its additional features like driver version resolution and proxy support.

Tips to remember
  • Open with a one-sentence definition of WebDriverManager, then a concrete Selenium example — never start with history or theory.
  • Be ready to whiteboard the WebDriverManager snippet live — panels often ask you to type it, not describe it.
  • Mention pinned browser images and cleanup of containers between runs — panels look for CI cost awareness.
Beginner Occasional 1 minQ75 / 80

Q75.How do you click on an element in Selenium?

Asked byCapgeminiTCSAmazonDeloitte
Why interviewers ask this

Hands-on "how would you click on an element" questions reveal whether you've actually shipped Selenium code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

element.click() clicks at the center of the element. The element must be visible and enabled. Selenium scrolls to the element automatically if needed. Alternative click methods: (1) JavaScript click — ((JavascriptExecutor) driver).executeScript("arguments[0].click();", element); — useful when normal click fails due to overlapping elements. (2) Actions class click — new Actions(driver).moveToElement(element).click().perform(); — for precise cursor positioning. (3) Submit — element.submit(); — works on form elements. Common click failures: element not visible, element covered by another element, element not yet loaded, or intercepted click. Use waits to ensure clickability before clicking.

Tips to remember
  • Walk through click on an element as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the click on an element snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Confidence check

If you can confidently answer the Selenium Fundamentals questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

5. Scenario-Based Problem Solving

Advanced Occasional 1 minQ76 / 80

Q76.Scenario: Your test passes locally but fails on CI/CD. How do you debug?

Asked byWiproCapgeminiTCSAmazon
Why interviewers ask this

Scenario questions on Scenario: Your test passes locally but fails on CI/CD. How do you debug check whether you can turn Selenium knowledge into action inside a real team. Panels want a diagnosis, a first step, a validation plan, and a rollback — in that order.

Detailed explanation

Common causes: (1) Timing differences — CI/CD is slower; add explicit waits. (2) Screen resolution — CI may have different viewport; set explicit window size. (3) Browser version differences — ensure CI has the same browser version. (4) No display server — use headless mode with --headless=new --no-sandbox --disable-dev-shm-usage. (5) Network restrictions — CI may block external resources. Debugging steps: (a) Add detailed logging. (b) Capture screenshots and HTML source on failure. (c) Run CI build with same browser options locally (headless). (d) Check CI logs for timeouts. (e) Use video recording in CI (BrowserStack, Sauce Labs). (f) Compare locale, timezone, language settings.

Tips to remember
  • Follow diagnose → contain → fix → prevent when walking through the Scenario: Your test passes locally but fails on CI/CD. How do you debug scenario. Skipping "prevent" is the most common miss.
  • Be ready to whiteboard the Scenario: Your test passes locally but fails on CI/CD. How do you debug snippet live — panels often ask you to type it, not describe it.
  • State that you never mix wait strategies and never use a hard sleep, then give the timeout value you actually run in CI.
Advanced Occasional 1 minQ77 / 80

Q77.Scenario: Your test clicks a button but nothing happens. How do you solve it?

Asked byAmazonDeloitteCognizantIBM
Why interviewers ask this

Scenario questions on Scenario: Your test clicks a button but nothing happens. How do you solve it check whether you can turn Selenium knowledge into action inside a real team. Panels want a diagnosis, a first step, a validation plan, and a rollback — in that order.

Detailed explanation

(1) Check ElementClickInterceptedException — another element may cover the button. (2) Use JavaScript click as workaround: js.executeScript("arguments[0].click();", button);. (3) Verify element is enabled: Assert.assertTrue(button.isEnabled());. (4) Wait for element to be clickable: wait.until(ExpectedConditions.elementToBeClickable(button)).click();. (5) Scroll to element first: new Actions(driver).moveToElement(button).click().perform();. (6) Check if button is inside an iframe — switch to it. (7) Check if there's a loading overlay — wait for it to disappear. (8) Verify button's JavaScript event listeners aren't blocked — use CDP to check console errors.

Tips to remember
  • Follow diagnose → contain → fix → prevent when walking through the Scenario: Your test clicks a button but nothing happens. How do you solve it scenario. Skipping "prevent" is the most common miss.
  • Be ready to whiteboard the Scenario: Your test clicks a button but nothing happens. How do you solve it snippet live — panels often ask you to type it, not describe it.
  • Finish by saying you always return to the default content after frame work — forgetting that is the classic failure this question hunts for.
Advanced Occasional 1 minQ78 / 80

Q78.Scenario: How do you automate a web page that loads content in a shadow DOM (open mode)?

Asked byTCSAmazonDeloitteCognizant
Why interviewers ask this

Scenario questions on Scenario: How do you automate a web page that loads content in a shadow DOM (open mode) check whether you can turn Selenium knowledge into action inside a real team. Panels want a diagnosis, a first step, a validation plan, and a rollback — in that order.

Detailed explanation

Selenium 4 supports open shadow DOM natively: SearchContext shadowRoot = driver.findElement(By.cssSelector("my-component")).getShadowRoot(); WebElement button = shadowRoot.findElement(By.cssSelector(".btn")); button.click();. For nested shadow DOMs: SearchContext outerShadow = driver.findElement(By.tagName("outer-component")).getShadowRoot(); SearchContext innerShadow = outerShadow.findElement(By.cssSelector("inner-component")).getShadowRoot(); WebElement target = innerShadow.findElement(By.id("target"));. For closed shadow DOM (encapsulated), use JavaScript: return document.querySelector('my-component').shadowRoot.querySelector('.target'); — but closed mode intentionally blocks access.

Tips to remember
  • Follow diagnose → contain → fix → prevent when walking through the Scenario: How do you automate a web page that loads content in a shadow DOM (open mode) scenario. Skipping "prevent" is the most common miss.
  • Be ready to whiteboard the Scenario: How do you automate a web page that loads content in a shadow DOM (open mode) snippet live — panels often ask you to type it, not describe it.
  • Name the exact API you'd use to pierce shadow roots and mention that closed shadow roots need a test hook from developers.
Advanced Occasional 1 minQ79 / 80

Q79.Scenario: How do you test a single-page application with complex state management?

Asked byCognizantIBMInfosysWipro
Why interviewers ask this

Scenario questions on Scenario: How do you test a single-page application with complex state management check whether you can turn Selenium knowledge into action inside a real team. Panels want a diagnosis, a first step, a validation plan, and a rollback — in that order.

Detailed explanation

(1) Understand the app state lifecycle (Redux store, Vuex, or component state). (2) Use CDP/CDP to evaluate JavaScript state: Object state = js.executeScript("return window.__REDUX_STORE__.getState();");. (3) Assert specific state values: Map<String, Object> state = (Map<String, Object>) state; String userRole = (String) ((Map<String, Object>)state.get("auth")).get("role"); Assert.assertEquals("admin", userRole);. (4) Test navigation via client-side routing: verify URL changes and component updates. (5) Test browser back/forward buttons. (6) Test state persistence after page refresh. (7) Test state reset on logout. (8) Use CDP to monitor network requests triggered by state changes.

Tips to remember
  • Follow diagnose → contain → fix → prevent when walking through the Scenario: How do you test a single-page application with complex state management scenario. Skipping "prevent" is the most common miss.
  • Be ready to whiteboard the Scenario: How do you test a single-page application with complex state management snippet live — panels often ask you to type it, not describe it.
  • Bring up explicit waits, Page Object Model, or grid execution — the three areas Selenium panels probe next.
Advanced Occasional 1 minQ80 / 80

Q80.Scenario: How do you handle a website that detects and blocks automation?

Asked byDeloitteCognizantIBMInfosys
Why interviewers ask this

Scenario questions on Scenario: How do you handle a website that detects and blocks automation check whether you can turn Selenium knowledge into action inside a real team. Panels want a diagnosis, a first step, a validation plan, and a rollback — in that order.

Detailed explanation

(1) Disable automation indicators: options.addArguments("--disable-blink-features=AutomationControlled"); options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); options.setExperimentalOption("useAutomationExtension", false);. (2) Override navigator.webdriver: js.executeScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined});");. (3) Use realistic user-agent: options.addArguments("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36...");. (4) Add random delays between actions: Thread.sleep(random.nextInt(1000) + 500);. (5) Randomize mouse movements: use Actions class with varied coordinates. (6) Use residential proxies for IP rotation. (7) Add browser fingerprint randomization (Canvas, WebGL, Font). Note: Only use these for testing your own applications, not for scraping or bypassing anti-automation on third-party sites.

Tips to remember
  • Follow diagnose → contain → fix → prevent when walking through the Scenario: How do you handle a website that detects and blocks automation scenario. Skipping "prevent" is the most common miss.
  • Be ready to whiteboard the Scenario: How do you handle a website that detects and blocks automation snippet live — panels often ask you to type it, not describe it.
  • Call out test isolation and shared-state risk (data, sessions, ports) before you talk about worker counts.
RelatedQ78
Confidence check

If you can confidently answer the Scenario-Based Problem Solving questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

Quick revision

  1. Q1: What is Selenium — Selenium is an open-source suite for automating web browsers.
  2. Q2: What are the components of Selenium — Selenium IDE — record-and-playback browser extension Selenium WebDriver — code-first API (the main one) Selenium Grid — distributed / parallel execution
  3. Q3: What is WebDriver — The W3C-standard programming interface for controlling a browser.
  4. Q4: How do you set up Selenium with Java + Maven — &lt;dependency&gt; &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt; &lt;artifactId&gt;selenium-java&lt;/artifactId&gt; &lt;version&gt;4.28.0&lt;/version&gt; &lt;/dependency&g
  5. Q5: Do you still need to download ChromeDriver manually — No — Selenium 4.6+ ships Selenium Manager , which auto-downloads the right driver.

Frequently asked questions

1.What are the top 20 Selenium interview questions for 2026?
The 2026 short-list covers: WebDriver vs Selenium RC, explicit vs implicit waits, relative locators (above/below/near), Selenium 4 CDP access, Selenium Grid 4 architecture, Page Object Model, handling iframes and shadow DOM, file uploads/downloads, Actions API, JavaScriptExecutor, headless mode, parallel execution with TestNG, data-driven testing, reporting (Allure/ExtentReports), CI/CD integration, dynamic XPath, stale element handling, browser profile management, network interception via CDP, and flaky-test debugging. All 20 are covered in the question bank below with sample answers.
2.Selenium vs Playwright — which should I learn first?
Learn Selenium first if you're targeting enterprise Java roles, BFSI/healthcare clients, or teams with existing Grid-based suites. Pick Playwright first for greenfield TypeScript/Node stacks, faster local execution, and modern auto-wait. Most senior SDETs end up knowing both — Selenium for breadth of jobs, Playwright for modern speed.
3.Are these Selenium questions asked at FAANG companies?
Yes — the question bank is sourced from real loops at FAANG and FAANG-adjacent companies (Amazon, Microsoft, Google, Meta, Atlassian, Salesforce, Flipkart, Swiggy). FAANG SDET rounds lean on framework design, parallelism, Grid architecture, CI/CD, and scenario debugging — all covered in sections 7–12.
4.Do you provide sample answers?
Every Selenium interview question on this page ships with a senior-SDET-written sample answer, and many include Java/WebDriver code snippets. You can also rehearse the answers out loud against our AI mock interviewer for instant scoring.
5.Is Selenium still in demand in 2026?
Yes. Selenium remains the most-requested automation tool in QA/SDET job postings worldwide — especially in India, the US, and Europe — because of its Java ecosystem, Grid scalability, and decade-long install base in regulated industries. Playwright is growing fast, but Selenium roles still outnumber it 3:1 in 2026 listings.
6.How do I handle stale element reference exceptions in Selenium WebDriver?
StaleElementReferenceException fires when the DOM node your WebElement pointed to was re-rendered by the framework (React/Angular re-mount). Three fixes senior SDETs use: (1) re-locate the element inside the action — never cache a WebElement across page updates; (2) wrap the interaction in an ExpectedConditions.refreshed(elementToBeClickable(By.id("btn"))) wait; (3) for lists, re-query driver.findElements() before every iteration rather than looping over a cached List<WebElement>. In interviews, always mention that Thread.sleep() is not a fix — it masks the race condition instead of resolving it.
7.What is the difference between findElement and findElements in Selenium?
findElement() returns a single WebElement and throws NoSuchElementException when the locator matches zero nodes — use it for a required element you'll act on. findElements() returns List<WebElement>, returns an empty list (never throws) when nothing matches, and is the correct choice for (a) presence checks (list.isEmpty()), (b) iterating over rows/cards, or (c) fetching a count. A common interview trap: candidates use findElement inside try/catch to check presence — that's slow and noisy in logs; findElements(...).isEmpty() is the idiomatic pattern.
8.How much salary can I expect with 3 years of Selenium experience in India?
Based on our QA Jobs Radar live feed (Jun 2026), SDETs with 3 YOE and Selenium + Java + TestNG + CI/CD experience earn ₹12–18 LPA at Indian product companies (median ₹14.8 LPA), ₹9–13 LPA at services companies (TCS, Infosys, Wipro, Cognizant), and $70K–$95K USD at India-based roles for US clients. Adding Selenium 4 CDP, Grid 4, and Docker knowledge typically pushes offers 15–25% higher — see the live salary bands on our SDET roadmap.
9.Is Selenium a good choice for QA freshers in 2026?
Yes — Selenium still tops the JD frequency chart for entry-level QA roles worldwide. Learn it first, then add Playwright to modernize your CV.
10.How many Selenium questions should a fresher prep?
Master 25–30 fundamentals (locators, waits, POM, TestNG basics) — that covers 80% of first-round questions. Then read our 300-Q hub for depth.
11.Do freshers need to know Selenium Grid?
Basic understanding (what it is, why parallel matters) is enough. Deep Grid architecture is a mid-level topic.
12.What language should a fresher pick for Selenium?
Java for the most jobs, Python for the fastest learning curve. JavaScript/TypeScript only if targeting Node shops.

Selenium QA jobs hiring now

Live, indexable Selenium openings — updated daily in Jobs Radar.

Browse all QA jobs on Jobs Radar

Loading current openings…

Home