21 Selenium Interview Questions & Answers to Know (Basic to Advanced)

how to answer Selenium Interview Questions
Summary:

Preparing for a Selenium interview? Here are the top Selenium interview questions that you should know and how to answer them well.

Are you about to hire a quality assurance analyst, automation tester, software engineer in test, or any other Selenium-related positions?

To hire the best Selenium developer, you’ll have to give your candidates a technical exam assessing their knowledge of this industry-favorite automation and testing framework.

In this guide, we walk you through all the important Selenium interview questions and answers you might want to include in your own interview guide. From the fundamentals to the advanced, we’ll give you common questions on Selenium, expected answers, and an explanation of what you, the technical recruiter, should look for when asking the questions.

Let’s get to it, shall we?

Looking to hire the best remote developers? Explore HireAI to see how you can:

⚡️ Get instant candidate matches without searching
⚡️ Identify top applicants from our network of 300,000+ devs with no manual screening
⚡️ Hire 4x faster with vetted candidates (qualified and interview-ready)

Try HireAI and hire top developers now →

Basic Selenium Interview Questions

What is automation testing, and what are its advantages?

It is key that a test engineer (regardless of discipline) knows from a high level the basic definition of automated testing, as well as its advantages over manual testing.

Test automation is the use of software (separate from that being tested) to control the execution of tests and compare the actual results with the expected results.

Any of the following types of tests may be automated:

  1. Unit testing
  2. Smoke testing
  3. Functional testing
  4. Integration testing
  5. Regression testing
  6. Software testing services

Creating automation tests requires an upfront initial cost by the organization, but it has the following benefits:

  1. Increases efficiency
  2. Ensures consistency of tests
  3. Wider test coverage
  4. Reduced manual testing
  5. Reduced long-term time and cost (requires initial time/cost investment)
  6. Reliability in results
  7. Tests can run 24/7 in parallel at any scale
  8. The ability to reuse (test cases can be modified/ duplicated)

What are the Selenium suite components?

There are four components of Selenium: (1) Selenium IDE, (2) RC, (3) WebDriver, and (4) Grid.

Selenium IDE: The simplest, and easiest to learn, it is a Firefox plugin that is easy to use and install. Because of it’s simplicity, it has limitations and should only be used for prototyping.

Selenium Remote Control (RC): The initial flagship testing framework for Selenium, it allows cross-browser and cross-platform testing using a variety of different languages.

WebDriver: The most modern Selenium framework, WebDriver controls the browser directly by communicating with it. It implements a more modern and stable approach to automating browser actions.

Selenium Grid: A tool used together with Selenium RC to run parallel tests across different machines at the same time.

The Selenium suite components are the foundation of any Selenium project, and this is required knowledge for any Selenium test engineer.

What are the testing types supported by Selenium?

Selenium supports Acceptance, Functional, Performance, End-to-End, Smoke, Sanity, UI, Integration, and Regression Testing.

Knowing the test types supported by Selenium demonstrates that the candidate is familiar with structured, well-known test methodologies.

What is the same-origin policy and how is it handled?

The same-origin policy is a common security best practice. Candidates that have worked in organizations with a mature security posture will have encountered same-origin policies.

The same-origin policy prohibits JavaScript code from accessing elements from a domain that is different from where it was launched. This is a security measure, and it ensures that content from your site will never be accessible by a script within another site.

A workaround for the same-origin policy is to use Selenium Server to proxy traffic between the browser and the application for testing to mask it under a fictional URL, bypassing same-origin policy restrictions.

What is Selenese? What are the three primary types of commands in Selenese?

Selenese is the set of selenium commands which are used to perform operations on the web in Selenium IDE.

The three primary types are:

  1. Actions: Commands which can change the condition of an application (clicks, etc.).
  2. Accessors: Verify the state of the application.
  3. Assertions: Used for checking the state of an application against expected conditions.

Candidates who correctly answer this question show familiarity with Selenium and its commands and demonstrate their ability to communicate at higher tiers. Knowing the three primary types allows them to collaborate better with their peers.


Check out our entire set of software development interview questions to help you hire the best developers you possibly can.

If you’re a developer, familiarize yourself with the non-technical interview questions commonly asked in the first round by HR recruiters and the questions to ask your interviewer!

Arc is the radically different remote job search platform for developers where companies apply to you. We’ll feature you to great global startups and tech companies hiring remotely so you can land a great remote job in 14 days. We make it easier than ever for software developers and engineers to find great remote jobs. Sign up today and get started.


What is meant by a locator and name a few different types of locators present in Selenium.

Locators are a fundamental part of working with Selenium, so it is imperative that a candidate knows locators very well when studying interview questions for Selenium.

locator is a command that tells Selenium IDE which GUI elements it needs to operate on in the DOM.

A few example locators in Selenium are as follows:

  • By CSS_ID – find_element_by_id
  • By CSS class: find_element_by_class_name
  • By name attribute: find_element_by_name
  • By DOM structure or XPath: find_element_by_xpath
  • By link text: find_element_by_link_text
  • By partial link text: find_element_by_partial_link_text
  • By HTML tag name: find_element_by_tag_name

What are the types of waits supported by WebDriver?

Test automation scripts are often asynchronous, so understanding the different types of waits and when to use them are essential.

There are three types of waits in Selenium WebDriver:

  1. Implicit Wait: Waits for certain number of seconds before throwing an exception. Implicit wait applies to all elements in a test script.
  2. Explicit Wait: Waits for certain conditions on the page before throwing an exception (or a maximum time exceeded). Applies only to specific elements as intended by the user.
  3. Fluent Wait: Defines the maximum amount of time for Selenium WebDriver to wait for a certain condition to appear.

Explain the various navigation commands supported by Selenium.

Similar to how the native browser works, Selenium WebDriver supports page navigation with the following commands:

  1. to(String arg)
  2. back()
  3. forward()
  4. refresh()

This is basic-level knowledge, and all Selenium test engineers should know this.

What is XPath, and can you give an example?

XPath is an XML path for navigation through an XML document to find an element on a given document.

There are different types of locators that can be utilized in XPath:

  1. ID
  2. Classname
  3. Name
  4. Link text
  5. CSS path

There are two types of XPathAbsolute and Relative.

An example absolute path to find an input with name uid:

<input name=“uid”/>

would be

Xpath=//input[@name='uid']

In Selenium automation, if the elements cannot be found by general locators, XPath must be used. XPath allows Selenium to navigate more complex DOM structures. Candidates who have not used XPath are less-likely to have experience testing complex web applications, which is why these types of Selenium automation interview questions are asked.

What is the difference between the typeKeys() and type() commands?

type() is used when you need to put text into an input field.

typeKeys() simulates each keystroke and is useful for when applications use autocompletes or autosuggests in search fields.

Candidates who can articulate this subtle nuance between type()/typeKeys() demonstrate an attention to detail and care. The commands are very different and will trigger different events in code.

Advanced Selenium Interview Questions

The following questions test a candidate’s hands-on experience with writing Selenium tests. Candidates should be able to answer at least 6 of the 10 questions below.

How to type text into an input box using Selenium?

To type text into an inbox box using Selenium WebDriver, you’ll first need to locate the element using findElement(). You can locate the input using a locator like By.id()By.name()By.path()By.CSSSelector().

Once you’ve located the element, you can use the sendKeys function to send a string to the input box.

Understanding locators and the sendKeys() methods in Selenium play an essential role in automating test cases that interact with forms. Since this is one of the most common use cases, it is foundational knowledge for any QA Engineer.

Clicking an element on a website is the most common use case for any website. It is essential to any QA role to understand how to do so.

To click a hyperlink in Selenium, use the .findElement function and use a locator. Once you have the element, use the .click() function.

Example:

webDriver.findElement(By.xpath(“//a[@href=‘/about’)).click();

How to assert the title of a webpage?

In WebDriver, you can assert the title of a page by using the Assert.assertEquals() function combined with the getTitle() function.

e.g. Assert.assertEquals("A Webpage Title",driver.getTitle());

How to mouse hover over a web element?

To hover over a web element requires you first create an Action class:

Actions mouseHoverDemo = newActions(driver);

Next we need to locate the target element where we want to move our mouse to:

WebElement target = driver.findByElement(use any By. locator);

Finally, let’s move to the element and execute the action.

mouseHoverDemo.moveToElement(target).perform();

Understanding how to use the Actions class in Selenium is imperative for testing more advanced user interactions on a web page. With the Actions class and the element to move to, we must invoke the perform() function. As the interviewer, you may ask a follow-up question: “what happens when the perform() function is called?”

Let’s take a look at what happens internally when perform() is invoked:*

  1. Move Mouse Action: Mouse cursor is moved to the middle of the element. The element is scrolled into view, and its location is calculated by getBoundingClientRect.
  2. Buildbuild() is called internally and is used to generate a composite action of all actions. In this case, we are only running one command.
  3. Performperform() executes all the actions we’ve queued up.

More experienced candidates should know the actions class as well as the nuances of the perform() function as they are tightly coupled.

How to select value in a dropdown?

  1. Import the Select package –

import org.openqa.selenium.support.ui.Select;

  1. Declare an instance of the Select class –

Select dropdownColour = new Select(driver.findElement(By.id(“colour”)));

  1. You can set the value by index –

dropdownColour.selectByIndex(2);

or alternatively, by value:

dropdownColour.selectByValue(“blue”);

Interaction with selects is another common use case when writing test cases for forms. This is essential knowledge for a QA.

How to take screenshots in WebDriver?

To take a screenshot in WebDriver, you need to use the getScreenshotAs function:

File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String screenshotBase64 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);

Taking screenshots can help check the application’s functionality and state. Screenshots can also help when your test fails so that you can help identify and communicate page states to the development team for bug triage. You may ask this Selenium framework interview question as a metric to determine how well your candidate documents deficiencies in an application, as screenshots can greatly enhance bug reports.

What is a pause on an exception in Selenium IDE?

pause on an exception is a feature in the Selenium IDE debugger to pause test script execution when a runtime error is thrown. This allows the developer to inspect the page to better debug the exception in real time.

What is the difference between a single and double slash in XPath?

XPath is generally used to locate DOM elements in more complex DOM trees. Companies may test your knowledge on XPath experience; candidates that have little to no familiarity with XPath demonstrate a lack of depth in test experience. Understanding the importance between a single slash and double slash is critical for any mid-level QA automation engineer.

A single slash / means a node is a direct descendant of the current node.

//div[@id=‘one’]/span[@id=‘two’] matches:

<div id="one">
    <span id="two">
</div>

A double slash // searches the entire tree of children.

//div[@id='one']//span[@id=two'] matches:

<div id="one">
  <div>
    <span id="two">
  </div>
</div>

Can CAPTCHA be automated? If so, how? If not, how do you test around it?

With the use of a good CAPTCHA, you cannot directly automate against it.

You have two primary options:

  1. The development team builds a backdoor, CAPTCHA is disabled in test builds.
  2. Use a service like https://www.deathbycaptcha.com/

Like some other Selenium coding interview questions, this one tests a candidate’s ability to work around an impossible solution. CAPTCHA, by design, is used to defeat automation. A candidate must work around this by adjusting the process, planning ahead, and communicating with other parts of the business to highlight this test roadblock.

What is POM (Page Object Model)? What are its advantages?

The Page Object Model is a design pattern which is commonly used in Selenium.

It’s advantages are:

  1. It makes test code more maintainable: Test classes are abstracted from the elements and operations performed on them, creating better modularity.
  2. It makes code more readable: Users can read the code more easily because of the separation of test classes and the underlying web elements.
  3. It makes the code more reusable: With the use of classes, we can reuse and re-instantiate objects without having to rewrite code.

Candidates that understand and employ Page Object Models demonstrate proficiency in creating higher-quality tests and are mindful of this methodology’s importance in larger teams.

Wrapping Up

Whether you’re asking Selenium with Java interview questions or Selenium with C# interview questions, these technical assessments can be difficult.

As the technical recruiter, don’t forget you’re not just looking for “4” when you ask your candidates, “what’s two plus two.” You want to know the why’s behind your candidates’ answers. Allow them to explain how they got to a particular answer, and when there are multiple possible right answers, explain why they chose their answers. Lastly, great candidates should always bring some questions to you. Make sure you test and score each candidate fairly and holistically by asking hard and soft skill questions.

We wish you the best of luck in hiring a Selenium testing developer!

You can also explore HireAI to skip the line and:

⚡️ Get instant candidate matches without searching
⚡️ Identify top applicants from our network of 250,000+ devs with no manual screening
⚡️ Hire 4x faster with vetted candidates (qualified and interview-ready)

Try HireAI and hire top developers now →

Written by
Arc Team