Skip to content
CompanyBenchCompanyBench

Selenium interview questions and answers

Selenium interview questions with short answers on WebDriver, locators, waits, frameworks, windows, alerts, the Actions class and XPath for test engineers.

These questions cover what interviewers ask test automation engineers most: WebDriver, locators, waits, frameworks, and handling windows, alerts and file uploads.

Hiring for this skill? See how we hire QA and test automation engineers, or read our Java interview questions.

Frequently asked questions

What is Selenium WebDriver and how does it work?

Selenium WebDriver is a framework for automating web applications. It talks to the browser directly through the browser's own native automation support, so tests drive a real browser the way a user would.

What types of locators does Selenium support?

ID, Name, Class Name, Tag Name, CSS Selector, Link Text, Partial Link Text and XPath. Each is a way of finding an element on the page.

What is the difference between implicit and explicit waits?

An implicit wait sets a default delay that applies globally to every element lookup. An explicit wait applies to a specific element and waits until a defined condition is met, such as the element becoming clickable.

Which test automation frameworks are commonly used with Selenium?

Data-driven, keyword-driven, hybrid and behaviour-driven development (BDD) frameworks, usually built with TestNG, JUnit or Cucumber.

How do you handle file uploads in Selenium?

Call sendKeys with the file path on the input element of type 'file'. If the upload opens a native OS dialog, use a third-party tool such as AutoIt or the Java Robot class.

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

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

How do you handle multiple windows or tabs?

Call getWindowHandles() to get the handles of all open windows, then switchTo().window(handle) to move to the one you need.

What is the Actions class used for?

It handles complex user interactions: mouse hover, drag and drop, double-click and keyboard actions.

How do you handle JavaScript alerts, prompts and confirms?

Switch to the alert with driver.switchTo().alert(), then call accept(), dismiss(), getText() or sendKeys() as needed.

What is the difference between absolute and relative XPath?

Absolute XPath starts from the root html element and breaks easily when the page structure changes. Relative XPath starts from any element using // and holds up better when the DOM changes.