Skip to content
chatgpt image feb 22, 2026, 07 27 39 pm QATRIBE

QA, Automation & Testing Made Simple

chatgpt image feb 22, 2026, 07 27 39 pm QATRIBE

QA, Automation & Testing Made Simple

  • Home
  • Blogs
  • Git
  • Playwright
  • Selenium
  • API Testing
    • API Authentication
    • REST Assured Interview Questions
    • API Testing Interview Questions
  • Java
    • Java Interview Prepartion
    • Java coding
  • Test Lead/Test Manager
  • Cucumber
  • TestNG
  • Home
  • Blogs
  • Git
  • Playwright
  • Selenium
  • API Testing
    • API Authentication
    • REST Assured Interview Questions
    • API Testing Interview Questions
  • Java
    • Java Interview Prepartion
    • Java coding
  • Test Lead/Test Manager
  • Cucumber
  • TestNG
Close

Search

Subscribe
Top 50 Selenium Interview Questions and Answers for Automation Testers with WebDriver Java examples
BlogsSelenium

Top 50 Selenium Interview Questions and Answers (2026) – Ultimate Guide for Automation Testers

By Ajit Marathe
9 Min Read
0

In this blog ,we will discuss about most asked Selenium Interview Questions.

Selenium is the most widely used automation testing tool in modern software development. Almost every company that practices automation testing uses Selenium WebDriver for browser automation.

If you are preparing for a QA Automation Engineer, Test Lead, or Automation Architect role, understanding Selenium concepts deeply is essential.

This guide covers Top 50 Selenium Interview Questions with detailed explanations and code examples to help you crack automation interviews.

1.What is Selenium?

Selenium is an open-source automation testing framework used to automate web browsers. It supports multiple programming languages like Java, Python, C#, and JavaScript.

Selenium is mainly used for:

  • Web application testing
  • Regression automation
  • Cross-browser testing
  • CI/CD pipeline automation

Main Selenium components include:

  • Selenium IDE
  • Selenium WebDriver
  • Selenium Grid

Example Selenium WebDriver code in Java:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SeleniumExample {    
public static void main(String[] args) {        
WebDriver driver = new ChromeDriver();
        driver.get("https://google.com");       
 System.out.println(driver.getTitle());       
 driver.quit();
    }
}

2.What are the components of Selenium?

This is starter of Selenium Interview. Selenium consists of four main components:

Selenium IDE

A browser plugin used for record and playback testing.

Selenium RC

The older Selenium tool that allowed running scripts via a server.

Selenium WebDriver

The most commonly used Selenium tool that interacts directly with browsers.

Selenium Grid

Used to run tests in parallel across multiple browsers and machines.

Example Selenium Grid command:

java -jar selenium-server.jar standalone

3.What is Selenium WebDriver?

Selenium WebDriver is a browser automation API that directly communicates with browsers through drivers like:

  • ChromeDriver
  • GeckoDriver
  • EdgeDriver

WebDriver follows the W3C WebDriver protocol.

Example:

WebDriver driver = new ChromeDriver();
driver.get("https://qatribe.in");

4.What are Locators in Selenium?

One of the common Selenium Interview Questions.

Locators are used to identify elements on a web page.

Common Selenium locators include:

  • ID
  • Name
  • Class Name
  • XPath
  • CSS Selector
  • Link Text

Example:

driver.findElement(By.id("username")).sendKeys("admin");

5.What is XPath in Selenium?

XPath is used to locate elements in an XML or HTML document.

Types of XPath:

Absolute XPath

/html/body/div/input

Relative XPath

 //input[@id='username']

Example:

driver.findElement(By.xpath("//input[@name='email']")).sendKeys("test@test.com");

6.Difference between findElement and findElements

This is most important Selenium Interview Question.

findElement

Returns a single WebElement and throws an exception if not found.

findElements

Returns a list of elements and returns an empty list if none found.

Example:

List<WebElement> links = driver.findElements(By.tagName("a"));
System.out.println(links.size());

7.What are Waits in Selenium?

Without wait , no Selenium Interview will get over.

Waits help Selenium handle dynamic web elements.

Types of waits:

  • Implicit Wait
  • Explicit Wait
  • Fluent Wait

Example Explicit Wait:

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement element = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.id("login"))
);

8.What is Page Object Model (POM)?

Page Object Model is a design pattern used in Selenium automation frameworks.

Each web page is represented as a separate class containing elements and actions.

Benefits:

  • Code reusability
  • Easy maintenance
  • Better readability

Example:

public class LoginPage {WebDriver driver;
By username = By.id("username");
By password = By.id("password");
By loginBtn = By.id("login");
public LoginPage(WebDriver driver){
this.driver = driver;
}public void login(String user,String pass){
driver.findElement(username).sendKeys(user);
driver.findElement(password).sendKeys(pass);
driver.findElement(loginBtn).click();
}
}

9 What is TestNG in Selenium?

TestNG is a testing framework used with Selenium.

Features:

  • Test grouping
  • Parallel execution
  • Data driven testing
  • Test reporting

Example:

@Test
public void loginTest(){driver.get("https://example.com");
Assert.assertEquals(driver.getTitle(),"Home");
}

10.What is Selenium Grid?

Selenium Grid allows running tests in parallel across multiple browsers and machines.

Example scenario:

You can run tests simultaneously on:

  • Chrome
  • Firefox
  • Edge
  • Safari

Example configuration:

selenium-server.jar node

11.How do you handle dropdowns in Selenium?

Dropdowns are handled using the Select class.

Example:

Select dropdown = new Select(driver.findElement(By.id("country")));dropdown.selectByVisibleText("India");

12.How to handle alerts in Selenium?

Alerts and frames are very important during Selenium Interview. User should now uses and process to implement it.

Alerts are handled using the Alert interface.

Example:

Alert alert = driver.switchTo().alert();
alert.accept();

13.How to switch between frames?

Frames are switched using switchTo().

Example:

driver.switchTo().frame("frame1");

14 What is StaleElementReferenceException?

This exception occurs when the DOM changes and the element reference becomes invalid.

Solution:

Re-locate the element.

Example:

driver.findElement(By.id("refresh")).click();
WebElement element = driver.findElement(By.id("username"));

15.What is headless browser testing?

Most experienced automations tester will go through this Selenium Interview Questions.
Headless browser is very useful in terms of improve the scripts performance.

Headless browsers run without a UI.

Example Chrome headless:

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
WebDriver driver = new ChromeDriver(options);

16.How to take screenshot in Selenium?

Example:

TakesScreenshot ts = (TakesScreenshot) driver;
File src = ts.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(src,new File("error.png"));

17 How to perform mouse actions?

Using Actions class

Example:

Actions actions = new Actions(driver);actions.moveToElement(element).click().perform();

18 How to handle multiple windows?

Example:

String parent = driver.getWindowHandle();
for(String win : driver.getWindowHandles()){
driver.switchTo().window(win);
}

19.What is Fluent Wait?

Fluent wait allows defining:

  • polling interval
  • timeout
  • ignored exceptions

Example:

Wait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofSeconds(5));

20 What is the difference between CSS Selector and XPath?

CSS Selector is faster and shorter.

XPath is more powerful for complex DOM navigation.

Example CSS

driver.findElement(By.cssSelector("#username"));

Example XPath

driver.findElement(By.xpath("//input[@id='username']"));

21.What is Selenium Architecture?

Selenium architecture consists of:

Test Script → WebDriver API → Browser Driver → Browser

Example:

Test → Selenium API → ChromeDriver → Chrome Browser

22.What is Parallel Execution?

Parallel execution runs multiple tests simultaneously to reduce execution time.

Example TestNG:

<suite parallel="tests" thread-count="3">

23.How to handle dynamic elements?

Dynamic elements can be handled using:

  • contains()
  • starts-with()

Example:

driver.findElement(By.xpath("//button[contains(text(),'Login')]"));

24 What is Data Driven Testing?

Data Driven Testing runs tests using multiple data sets.

Example:

@DataProvider
public Object[][] data(){return new Object[][]{
{"admin","1234"},
{"user","1234"}
};
}

25.What is Cucumber in Selenium?

Cucumber enables BDD testing using Gherkin syntax.

Example:

Feature: LoginScenario: Valid login
Given user is on login page
When user enters credentials
Then login should be successful

26.What is the difference between Selenium and Playwright?

Both Selenium and Playwright are popular tools used for browser automation, but they differ in architecture and features.

Selenium

  • Oldest and most widely used automation tool
  • Requires browser drivers like ChromeDriver
  • Supports many languages (Java, Python, C#, Ruby)

Playwright

  • Developed by Microsoft
  • Supports auto-waiting
  • Faster execution due to modern architecture
  • Supports multi-tab and network interception easily

Example Selenium Code:

WebDriver driver = new ChromeDriver();
driver.get("https://example.com");

Example Playwright Code:

Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch();
Page page = browser.newPage();
page.navigate("https://example.com");

In interviews, Selenium is still more commonly used in enterprise automation frameworks, while Playwright is gaining popularity.


27.What is the difference between Selenium RC and WebDriver?

Selenium RC (Remote Control) was the older version of Selenium which required a server to run tests.

Selenium RC

  • Required a Selenium server
  • Slower execution
  • Used JavaScript to interact with browsers

Selenium WebDriver

  • Direct communication with browsers
  • Faster execution
  • Uses native browser automation APIs

Example WebDriver Code:

WebDriver driver = new ChromeDriver();
driver.get("https://google.com");

WebDriver replaced Selenium RC because it provides better performance and stability.


28.What are the limitations of Selenium?

Although Selenium is powerful, it has some limitations.

Major limitations

  • Cannot automate desktop applications
  • Cannot handle CAPTCHA directly
  • No built-in reporting
  • Requires programming knowledge
  • Difficult to automate images

Example scenario where Selenium cannot work:

CAPTCHA verification on login pages

Usually testers bypass CAPTCHA using test environments or mock APIs.


29 How do you handle file upload in Selenium?

File upload can be handled using the sendKeys() method.

Instead of interacting with the OS file dialog, Selenium directly sends the file path.

Example:

WebElement upload = driver.findElement(By.id("fileUpload"));
upload.sendKeys("C:\\Users\\Test\\file.txt");

This method works only when the upload element is an input type=”file”.


30.What is JavaScriptExecutor in Selenium?

JavaScriptExecutor allows executing JavaScript code directly inside the browser.

It is used when Selenium cannot interact with elements normally.

Example:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('login').click()");

Another example: Scroll page

js.executeScript("window.scrollBy(0,500)");

JavaScriptExecutor is useful for:

  • Scrolling pages
  • Clicking hidden elements
  • Handling complex DOM interactions

31 How do you handle Shadow DOM in Selenium?

Shadow DOM elements are encapsulated elements used in modern web components.

Standard Selenium locators cannot access them directly.

Example:

JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement shadowRoot = (WebElement) js.executeScript(
"return document.querySelector('shadow-host').shadowRoot");
WebElement element = shadowRoot.findElement(By.cssSelector("button"));

Handling Shadow DOM is becoming important because modern frameworks like Angular and Polymer use it.

32.What is a Selenium Automation Framework?

Most common Selenium Interview Question.

A Selenium automation framework is a structured approach to organize test automation code.

Common Selenium frameworks include:

  • Data Driven Framework
  • Keyword Driven Framework
  • Hybrid Framework
  • Behavior Driven Framework (Cucumber)

Typical framework components:

  • Page Object Model
  • Test scripts
  • Utility classes
  • Test data
  • Reporting

Example Framework Structure:

src
├── pages
├── tests
├── utilities
├── base
└── reports

33.How do you integrate Selenium with Maven?

In Selenium Interview , having knowledge of Maven is very important. Maven is used to manage project dependencies.

To use Selenium with Maven, we add dependencies in pom.xml.

Example:

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.18.1</version>
</dependency>

Benefits of Maven:

  • Dependency management
  • Build automation
  • Easy CI/CD integration

34.How is Selenium integrated with Jenkins?

Jenkins is used for continuous integration and automated test execution.

Typical flow:

Developer commits code → Jenkins triggers build → Selenium tests run → Report generated.

Example Maven command in Jenkins:

mvn clean test

Benefits:

  • Automated regression testing
  • CI/CD integration
  • Faster feedback cycle

35.How do you implement logging in Selenium?

Logging helps track test execution.

The most common logging library is Log4j.

Example:

Logger log = Logger.getLogger(TestClass.class);
log.info("Test execution started");
log.error("Login failed");

Benefits of logging:

  • Debugging failures
  • Detailed execution tracking
  • Better reporting

36.How do you retry failed tests in Selenium?

Failed tests can be retried using TestNG’s IRetryAnalyzer.

Example:

public class RetryAnalyzer implements IRetryAnalyzer {
int count = 0;
int maxRetry = 2;
public boolean retry(ITestResult result){
if(count < maxRetry){
count++;
return true;
}
return false;
}
}

Usage:

@Test(retryAnalyzer = RetryAnalyzer.class)

This helps reduce false failures due to unstable environments.

37.What is the difference between Soft Assert and Hard Assert?

Hard Assert

  • Stops test execution if assertion fails.

Example:

Assert.assertEquals(actual, expected);

Soft Assert

  • Allows test execution to continue.

Example:

SoftAssert soft = new SoftAssert();
soft.assertEquals(actual, expected);
soft.assertAll();

Soft assertions are useful when verifying multiple validations in one test.

38.How do you handle dynamic web tables?

Dynamic tables contain changing data.

Example:

List<WebElement> rows = driver.findElements(By.xpath("//table/tbody/tr"));
for(WebElement row : rows){String value = row.getText();
System.out.println(value);
}

You can also extract specific columns.

Example:

driver.findElement(By.xpath("//tr[2]/td[3]"));

39.How do you handle cookies in Selenium?

Cookies store session data in browsers.

Example:

Add Cookie

Cookie cookie = new Cookie("username","test");driver.manage().addCookie(cookie);

Get Cookies

Set<Cookie> cookies = driver.manage().getCookies();

Delete Cookies

driver.manage().deleteAllCookies();

Cookies help simulate logged-in user sessions.

40.How do you capture browser logs in Selenium?

Logs can be captured using browser logging preferences.

Example:

LogEntries logs = driver.manage().logs().get("browser");
for(LogEntry entry : logs){
System.out.println(entry.getMessage());
}

Logs help detect:

  • JavaScript errors
  • Network failures
  • Console warnings

41.What is WebDriverManager?

  • WebDriverManager automatically manages browser drivers.
  • Instead of downloading drivers manually, it downloads the correct version automatically.

Example:

WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();

Benefits:

  • No manual driver setup
  • Version compatibility
  • Faster framework setup

42.What are Selenium Best Practices?

Best practices improve automation stability.

Important practices include:

  • Use Page Object Model
  • Avoid Thread.sleep()
  • Use explicit waits
  • Keep test cases independent
  • Use meaningful locators

Example good locator:

driver.findElement(By.id("loginButton"));

Avoid fragile XPath like:

/html/body/div[3]/div[2]/button

43.How do you handle infinite scrolling?

Infinite scrolling loads content dynamically while scrolling.

Example:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");

Loop example:

while(true){
js.executeScript("window.scrollBy(0,1000)");
}

Used for testing:

  • Social feeds
  • Product listing pages

44.What types of automation frameworks are used in Selenium?

Common frameworks:

Linear Framework

Simple script-based approach.

Data Driven Framework

Uses external data sources like Excel.

Keyword Driven Framework

Uses keywords like Login, Click, Navigate.

Hybrid Framework

Combination of multiple frameworks.

Most companies use Hybrid Framework + POM.

45.How do you handle calendar controls in Selenium?

Calendars are handled by selecting specific dates.

Example:

driver.findElement(By.id("date")).click();
driver.findElement(By.xpath("//td[text()='15']")).click();

Dynamic calendar example:

driver.findElement(By.xpath("//span[text()='March']")).click();

46.How do you implement custom wait methods?

Sometimes built-in waits are not enough.

Custom wait example:

public void waitForElement(By locator){
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
}

Usage:

waitForElement(By.id("login"));

Custom waits improve framework reusability.


47.What is Extent Report in Selenium?

Extent Reports is a modern HTML reporting library.

Example:

ExtentReports extent = new ExtentReports();
ExtentTest test = extent.createTest("Login Test");
test.pass("Login successful");extent.flush();

Benefits:

  • Beautiful reports
  • Screenshots
  • Detailed logs

48.Can Selenium handle CAPTCHA?

No, Selenium cannot automate CAPTCHA.

CAPTCHA is designed to prevent automation bots.

Possible solutions:

  • Disable CAPTCHA in test environment
  • Use API authentication
  • Mock login services

Example:

Test environments usually bypass CAPTCHA

49.What are common Selenium coding challenges in interviews?

Common coding questions include:

  • Count number of links
  • Validate page title
  • Handle dynamic elements
  • Extract table data

Example coding challenge:

Count links on page

List<WebElement> links = driver.findElements(By.tagName("a"));
System.out.println("Total links: " + links.size());

These questions test practical Selenium knowledge.

50.How do you design a Selenium automation framework?

A good framework should include:

  • Page Object Model
  • TestNG or JUnit
  • Maven or Gradle
  • Reporting (Extent Reports)
  • Logging
  • CI/CD integration

Example Framework Architecture:

AutomationFramework
├── base
├── pages
├── tests
├── utilities
├── data
└── reports

Benefits:

  • Scalable automation
  • Maintainable tests
  • Easy team collaboration

Final Thoughts:

Preparing these Top 50 Selenium Interview Questions will significantly improve your chances of cracking Automation Engineer, QA Lead, and Test Architect interviews.

Focus on:

  • Selenium WebDriver concepts
  • Framework design
  • Coding practice
  • Real-world automation scenarios

Consistent practice with these questions will help you master Selenium automation testing and perform confidently in technical interviews.

External links for your reference:

Official Selenium Documentation

Selenium Official Website

Selenium GitHub Repository

WebDriver API Reference

🔥 Continue Your Learning Journey

Want to go beyond Java Arrays Questions and crack interviews faster? Check these hand-picked guides:

👉 🚀 Master TestNG Framework (Enterprise Level)
Build scalable automation frameworks with CI/CD, parallel execution, and real-world architecture
➡️ Read: TestNG Automation Framework – Complete Architect Guide

👉 🧠 Learn Cucumber (BDD from Scratch to Advanced)
Understand Gherkin, step definitions, and real-world BDD framework design
➡️ Read: Cucumber Automation Framework – Beginner to Advanced Guide

👉 🔐 API Authentication Made Simple
Master JWT, OAuth, Bearer Tokens with real API testing examples
➡️ Read: Ultimate API Authentication Guide

👉 ⚡ Crack Playwright Interviews (2026 Ready)
Top real interview questions with answers and scenarios
➡️ Read: Playwright Interview Questions Guide

Tags:

API AutomationAPI TestingAPI Testing ChecklistAPI Testing ToolsAPI Testing Tutorialautomation testing interview questionsAutomation Testing;Interview QuestionsEnd to End TestingPlaywrightPlaywright Tutorialplaywright vs seleniumPostmanPostman Interview QuestionsQA AutomationREST APIREST API TestingRest AssuredSeleniumselenium advanced interview questionsselenium automation engineer interview questionsselenium automation examplesselenium automation interview questionsselenium automation testing questionsselenium coding questionsselenium framework design questionsselenium framework interview questionsselenium interview questionsselenium java automation questionsselenium java code examplesselenium java interview questionsselenium locator strategiesselenium page object model interview questionsselenium parallel execution interview questionsselenium practical questionsselenium test automation interview questionsselenium tester interview questionsselenium testng interview questionsSelenium Tutorialselenium waits interview questionsSelenium WebDriverselenium webdriver architectureselenium webdriver coding questionsselenium webdriver examplesselenium webdriver interview questionsSelenium with JavaSelenium with Pythonselenium xpath interview questionsTest Automation
Author

Ajit Marathe

Follow Me
Other Articles
Top 50 automation testing interview questions with coding examples for beginners and experienced testers
Previous

50 Automation Testing Interview Questions: Real-World Scenarios

top 25 testng interview questions
Next

Top 25 TestNG Interview Questions for Automation Testers (Beginner to Intermediate)

No Comment! Be the first one.

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Recent Posts

    • Test Lead and Test Manager Interview Questions: The Ultimate Guide (2026)
    • REST Assured Interview Questions: The Complete Guide for 2026(Beginner to Architect Level)
    • Top 25 Playwright Interview Questions (2026) – Framework Design, Architecture & Best Practices
    • Playwright with TypeScript Setup: The Only Guide You Need in 2026
    • Cucumber Framework Tutorial for Beginners (2026) — QaTribe

    Categories

    • API Authentication
    • API Testing
    • API Testing Interview Questions
    • Blogs
    • Cucumber
    • Git
    • Java
    • Java coding
    • Java Interview Prepartion
    • Playwright
    • REST Assured Interview Questions
    • Selenium
    • Test Lead/Test Manager
    • TestNG
    • About
    • Privacy Policy
    • Contact
    • Disclaimer
    Copyright © 2026 — QATRIBE. All rights reserved. Learn • Practice • Crack Interviews