11 Essential Selenium Interview Questions *

Toptal sourced essential questions that the best Selenium developers and engineers can answer. Driven from our community, we encourage experts to submit questions and offer feedback.

Hire a Top Selenium Developer Now
Toptal logois an exclusive network of the top freelance software developers, designers, finance experts, product managers, and project managers in the world. Top companies hire Toptal freelancers for their most important projects.

Interview Questions


What functions/methods can you use to wait for a page to load, or some element on the page to show up?

View answer

To wait for a page to load, explicit wait can be used. Explicit waits stall until some specific condition is met. Although Thread.Sleep() is a form of explicit wait where the thread stalls for a specific duration of time, it may not be the most reliable way to wait for a page to load.

For example, rather than using something like:


… where the thread sleeps for 30 seconds (30,000 milliseconds), the following can be used:

WebDriverWait wait= new WebDriverWait(webDriver,30);

… where Selenium waits until the given element is visible on the page, or throws TimeoutException after waiting for 30 seconds.


What is Page Object Model and Page Factory in Selenium?

View answer

Page Object Model in Selenium is a design pattern where web pages are represented using classes. Variables in the class can then be used to hold references to elements on the web page, and methods can be used to implement behaviors. This allows an elegant way of implementing test routines that are both readable and easier to maintain and extend in the future.

setCredentials(user_name, user_password);

Page Factory is used to initialize every WebElement variable with a reference to a corresponding element on the actual web page using configured “locators”. Annotations, such as @FindBy, can be used to define strategies for looking up elements, along with the necessary information for identifying them:

@FindBy(how=How.NAME, using="username")
private WebElement user_name;

More about Page Object Model and Page Factory can be found here.


How do you deal with frame elements in Selenium on a page?

View answer

In order to manipulate frame and its content you must switch to it first. This is similar to how you have to switch to a different page before you can interact with it:


… where index is the zero-based index of the frame. Switching the frame directs all further interactions through the driver towards the selected frame. The frame method also works with name, element ID and reference to already located elements.

To switch back to the default frame, the defaultContent method can be used:


Apply to Join Toptal's Development Network

and enjoy reliable, steady, remote Freelance Selenium Developer Jobs

Apply as a Freelancer

What are some differences between CSS selector and XPath based locators?

View answer
  • CSS selectors are often easier to read than XPath. Most front-end developers are more likely to be familiar with CSS selectors already.

  • Support for CSS selectors is quite consistent across various modern web browsers, which is not the case with their XPath engines.

  • CSS selectors work faster than XPath.

For various reasons, such as the ones outlined above, Selenium “best practices” advise the use of CSS selectors over XPath.


How do you write a locator to identify paragraph elements that are the immediate child of a div element, or the descendent of a div element?

View answer

Immediate child:

An immediate child in XPath is defined indicated using “/”, while on CSS, it is indicated using “>”. For example, with XPath:


… and with CSS:

div > p


To find paragraph elements that are descendent to any div element (i.e. the paragraph element appears in the subtree rooted at the div element), we can use “//” in XPath, and just a whitespace in CSS:

div p

Briefly explain what the following snippet of Java code does:

WebElement sample = driver.findElement(By.xpath("//*[contains(text(), 'data')]"));
View answer

It defines a variable sample of type WebElement, and uses an XPath search to initialize it with a reference to an element that contains the text value “data”.


How can you send text input to a focused element?

View answer

This can be done by simulating key presses on the focused element. One way is to perform “actions” on the web driver object:

new Actions(webDriver).sendKeys(“some text”).perform();

An alternative way is to switch to the active element first, and send keys to it directly:

webDriver.switchTo().activeElement().sendKeys(“some text”);

Why do we use headless drivers? How can you visually investigate test failure when using headless drivers?

View answer

Headless drivers are typically used in continuous integration (CI) setups. Headless drivers, such as PhantomJS, provide all standard web browser functionalities, but run in the command-line. These drivers are based on command-line tools and don’t produce screen output, making them ideal for completely automated setups.

To be able to visually investigate test failures, the developer needs to implement mechanisms to capture screenshots, otherwise rely on command line output.


How are absolute XPaths different from relative XPaths? Why are relative XPaths typically preferred over absolute XPaths in automated tests?

View answer

Absolute XPaths, in terms of web pages, start with the root element:


Relative XPaths, on the other hand, usually start with “//”:


Even though both these XPaths probably refer to the same element on a certain web page, the former one is more likely to break with any change made to the page. For example, moving the table to inside of a div element will stop the absolute XPath from being able to locate the th element. On the other hand, the relative XPath will still continue to work.


What is a hybrid framework in Selenium?

View answer

A hybrid framework is a combination of keyword- and data-driven frameworks.


What is StaleElementException ?

View answer

It is the exception thrown when the invoked element is no longer attached to the DOM for any reason.

There is more to interviewing than tricky technical questions, so these are intended merely as a guide. Not every “A” candidate worth hiring will be able to answer them all, nor does answering them all guarantee an “A” candidate. At the end of the day, hiring remains an art, a science — and a lot of work.

Why Toptal

Tired of interviewing candidates? Not sure what to ask to get you a top hire?

Let Toptal find the best people for you.

Hire a Top Selenium Developer Now

Our Exclusive Network of Selenium Developers

Looking to land a job as a Selenium Developer?

Let Toptal find the right job for you.

Apply as a Selenium Developer

Job Opportunities From Our Network

Submit an interview question

Submitted questions and answers are subject to review and editing, and may or may not be selected for posting, at the sole discretion of Toptal, LLC.

* All fields are required

Looking for Selenium Developers?

Looking for Selenium Developers? Check out Toptal’s Selenium developers.

Papuna Gagnidze

Freelance Selenium Developer
GeorgiaToptal Member Since November 21, 2019

Papuna is a highly skilled QA automation and DevOps engineer with experience in Linux system administration and network engineering. He has leadership experience in QA teams and skills for delivering high-quality end-to-end tests. Papuna has designed architectures and implemented scalable systems using microservices and serverless architecture.

Show More

Deniz Hamamcioglu

Freelance Selenium Developer
TurkeyToptal Member Since December 12, 2018

Deniz has over nine years of experience in software test automation, framework, and test architecture design. He led and mentored teams and created guidelines about testing. Deniz is an expert on Selenium, Cypress, Playwright, WebdriverIO, Protractor, and many other test automation technologies and programming languages. He communicates exceptionally well and has a keen eye for details. Deniz has been working remotely for the last couple of years, providing expert guidance across continents.

Show More

Jovana Rajkovic

Freelance Selenium Developer
SerbiaToptal Member Since March 22, 2018

For the past seven years, Jovana has worked as a QA engineer collaborating with various QA teams and on complex functional testing (manual and automation) on multiple types of applications. She's passionate about bug hunts and is known as a hard-working team player who loves to learn. Jovana thrives under pressure and this can be seen in her history of successfully dealing with deadlines and product deliveries.

Show More

Toptal Connects the Top 3% of Freelance Talent All Over The World.

Join the Toptal community.

Learn more