Selenium Interview Questions

The Test Lead
3 min readJan 29, 2024

Selenium Basics:

Q: What is Selenium WebDriver, and how does it differ from Selenium IDE?

A: Selenium WebDriver is a tool for automating web applications. It provides a programming interface for interacting with web elements and is more powerful than Selenium IDE, which is a record-and-playback tool.

Q: Explain the differences between implicit wait, and explicit wait.

A: Implicit wait sets a global timeout for the driver to wait for an element. Explicit wait waits for a specific condition to be met before proceeding.

Q: When would you use the driver.close() and driver.quit() methods in Selenium?

A: driver.close() closes the current browser window, while driver.quit() closes all browser windows and ends the WebDriver session. Use quit() to ensure all resources are released after testing.

Q: How can you handle multiple windows in Selenium WebDriver?

A: Use getWindowHandles() to get all window handles, switch between them using switchTo().window(handle), and close or interact with specific windows accordingly.

Locators and FindElement Strategies:

Q: Explain the differences between ID, Name, Class Name, and Tag Name locators in Selenium.

A: These are different types of locators used to find web elements. ID and Name are unique identifiers, Class Name and Tag Name match multiple elements. There could be multiple tags or classes with the same name.

Q: What is the XPath locator, and when would you prefer it over other locators?

A: XPath is a powerful locator that can traverse the XML structure of an HTML document. It’s useful when there are no unique identifiers, or for complex traversals.

Q: Compare XPath and CSS selectors. What are the pros and cons of each?

A: XPath is more flexible but may be slower. CSS selectors are faster and have better browser support. XPath allows backward and forward traversals, while CSS selectors are simpler and more readable.

Q: When would you prefer using a relative XPath over an absolute XPath?



The Test Lead

SDET at fintech company in NYC. Visit personal page Twitter @juss_bailey Youtube @The Test Lead