How to Use This Guide

These are the Selenium interview questions that appear most frequently in real interviews.

Each answer provides a concise explanation suitable for interview revision. For complete explanations, examples, and code samples, refer to the linked tutorial.

For the complete learning path, begin with the Complete Selenium Guide.

Advertisement

Selenium Fundamentals (Q1–8)

Q1. What is Selenium WebDriver?

An open-source browser automation tool that communicates directly with browsers using browser-specific drivers.

Learn more: Fundamentals


Because it is:

  • Open source
  • Free
  • Supports multiple browsers
  • Supports multiple programming languages
  • Backed by a large community

Learn more: Fundamentals


Q3. What are Selenium's limitations?

Some common limitations include:

  • Cannot automate desktop applications
  • No built-in reporting
  • Cannot automate CAPTCHA
  • Cannot automate barcode scanning
  • Requires external tools for image-based testing and OS file dialogs

Learn more: Fundamentals


Q4. Explain the Selenium WebDriver architecture.

Execution flow:

Test Script → Language Bindings → WebDriver Protocol → Browser Driver → Browser

Learn more: Fundamentals


Q5. Is WebDriver a class or an interface?

WebDriver is an interface.

Example:

WebDriver driver = new ChromeDriver();

This is an example of upcasting.

Learn more: Fundamentals


Q6. What is WebDriver's super interface?

SearchContext

Learn more: Fundamentals


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

Learn more: Fundamentals


Q8. Can CAPTCHA be automated?

No.

CAPTCHA is specifically designed to prevent automation. In testing environments, it is generally disabled or bypassed.

Learn more: Fundamentals


Locators & XPath (Q9–15)

Q9. What are Selenium locators?

Methods used to identify web elements.

Common locator strategies include:

  • id
  • name
  • className
  • tagName
  • linkText
  • partialLinkText
  • cssSelector
  • xpath

Learn more: Locators & XPath


Q10. What is the By class?

The By class provides locator strategies that are passed to methods such as findElement().

Learn more: Locators & XPath


Q11. What is the difference between Absolute XPath and Relative XPath? Which is faster?

  • Absolute XPath starts from the root element.
  • Relative XPath starts with //.

Relative XPath is shorter, more maintainable, faster, and preferred in real projects.

Learn more: Absolute vs Relative XPath


Q12. What are XPath Axes?

XPath Axes navigate elements using DOM relationships.

Examples include:

  • parent
  • child
  • ancestor
  • descendant
  • following-sibling

Learn more: Locators & XPath


Q13. How do you locate dynamic elements?

Use Relative XPath together with functions like:

  • contains()
  • starts-with()

or XPath Axes anchored to nearby stable elements.

Learn more: Locators & XPath


Q14. How do you handle duplicate IDs?

Use:

  • findElements()
  • Index-based selection
  • More specific XPath or CSS selectors

Learn more: Locators & XPath


Q15. What are CSS Selectors and their limitations?

CSS Selectors are fast and readable.

Unlike XPath, CSS cannot traverse upward in the DOM hierarchy.

Learn more: Locators & XPath


Commands & WebElements (Q16–21)

Q16. What is the difference between get() and navigate()?

  • get() opens a URL.
  • navigate() supports:
    • to()
    • back()
    • forward()
    • refresh()

Learn more: Browser Commands


Q17. What is the difference between findElement() and findElements()?

  • findElement() returns a single element.
  • findElements() returns a List and returns an empty collection when no matching elements exist.

Learn more: Browser Commands


Q18. What is the difference between close() and quit()?

  • close() closes the current browser window.
  • quit() closes every browser window and ends the WebDriver session.

Learn more: Browser Commands


driver.findElements(By.tagName("a")).size()

Learn more: Browser Commands


Q20. What do isDisplayed(), isEnabled(), and isSelected() do?

They verify:

  • Visibility
  • Enabled state
  • Selection state

Learn more: Browser Commands


Q21. How do you retrieve an element's location, size, or CSS value?

Use:

  • getLocation()
  • getSize()
  • getCssValue()

Learn more: Browser Commands


Waits & Synchronization (Q22–26)

Q22. How is synchronization achieved in Selenium?

Using:

  • Implicit Wait
  • Explicit Wait
  • Fluent Wait

Learn more: Waits


Q23. What is the difference between Implicit Wait and Explicit Wait?

  • Implicit Wait applies globally.
  • Explicit Wait targets a specific condition.

Learn more: Implicit vs Explicit vs Fluent Wait


Q24. What is Fluent Wait?

Fluent Wait extends Explicit Wait by allowing custom polling intervals.

Learn more: Waits


Q25. Why should Thread.sleep() be avoided?

Because it pauses execution for a fixed duration regardless of whether the element becomes available earlier.

Learn more: Waits


Q26. Which wait handles page loading?

Use pageLoadTimeout or an Explicit Wait based on page conditions.

Learn more: Waits


Forms, Alerts, Frames & Windows (Q27–33)

Q27. How do you handle dropdowns?

Using the Select class.

Common methods include:

  • selectByIndex()
  • selectByValue()
  • selectByVisibleText()

Learn more: Form Elements


Q28. How do you handle multi-select dropdowns?

Use Select together with isMultiple().

Learn more: Form Elements


Q29. How do you verify a checkbox or radio button is selected?

Use:

isSelected()

Learn more: Form Elements


Q30. How do you handle JavaScript alerts?

Switch to the alert using:

driver.switchTo().alert()

Then use:

  • accept()
  • dismiss()
  • getText()
  • sendKeys()

Learn more: Alerts, Frames & Windows


Q31. How do you handle frames?

Use:

switchTo().frame()

Return using:

defaultContent()

Learn more: Alerts, Frames & Windows


Q32. How do you handle multiple browser windows?

Retrieve all window handles using getWindowHandles() and switch between them.

Learn more: Alerts, Frames & Windows


Q33. How do you handle SSL certificate warnings?

Configure browser options or capabilities to accept insecure certificates.

Learn more: Alerts, Frames & Windows


Actions & JavaScriptExecutor (Q34–39)

Q34. How do you perform a right-click?

Using:

Actions.contextClick()

Learn more: Actions Class


Q35. What is the difference between build() and perform()?

  • build() prepares the action sequence.
  • perform() executes it.

Learn more: Actions Class


Q36. How do you perform drag-and-drop or mouse hover?

Use:

  • dragAndDrop()
  • moveToElement()

with build().perform().

Learn more: Actions Class


Q37. What is JavaScriptExecutor?

An interface used to execute JavaScript commands within the browser when standard Selenium actions are insufficient.

Learn more: JavaScriptExecutor


Q38. What is upcasting in Selenium?

Example:

WebDriver driver = new FirefoxDriver();

An interface reference points to a concrete implementation.

Learn more: Typecasting


Q39. How do you capture screenshots?

Typecast the driver to TakesScreenshot and call getScreenshotAs().

Learn more: Typecasting


Advanced Selenium Handling (Q40–43)

Q40. How do you upload files?

Use sendKeys() with the file path.

For operating-system dialogs, AutoIt can be used.

Learn more: Advanced Handling


Collect hyperlink URLs, send HTTP requests, and validate the returned response codes.

Learn more: Advanced Handling


Q42. How do you handle Ajax controls?

Use Explicit Waits instead of fixed delays.

Learn more: Advanced Handling


Q43. How do you create a dynamic XPath for table cells?

Use index-based XPath or XPath Axes such as:

  • ancestor::
  • following-sibling::

Learn more: Advanced Handling


TestNG, Selenium Grid & Maven (Q44–47)

Q44. Which TestNG annotations are commonly used?

Common annotations include:

  • @Test
  • @BeforeMethod
  • @AfterMethod
  • @BeforeClass
  • @AfterClass
  • @BeforeSuite
  • @AfterSuite
  • @DataProvider

Learn more: TestNG Essentials


Q45. What is the difference between Verify and Assert?

  • Assert stops execution immediately.
  • Verify (Soft Assert) continues execution and reports failures later.

Learn more: TestNG Essentials


Q46. How do you execute tests in parallel?

Configure parallel and thread-count in testng.xml.

Selenium Grid enables execution across multiple browsers and machines.

Learn more: Parallel & Grid


Q47. What is Selenium Grid?

A Hub-and-Node architecture that enables parallel and cross-browser test execution.

Learn more: Parallel & Grid


Framework & Project Questions (Q48–50)

Q48. What is the Page Object Model (POM)?

A design pattern where each page is represented by a class containing locators and reusable page actions.

Learn more: Frameworks & POM


Q49. What is Apache POI used for?

Reading and writing Excel files for data-driven automation testing.

Learn more: Data-Driven Testing


Q50. What Selenium challenges have you faced in projects?

Common challenges include:

along with the solutions implemented in real projects.

Learn more: Project & Process


Next Steps

Continue your interview preparation with:

  • Complete Selenium Guide
  • Java Coding Programs Guide
  • Automation Framework Guide
  • SDET Interview Guide