Latest Selenium Interview Questions You Must Know

Are you doing Web UI automation and preparing for a Selenium interview? If yes, then you are at the right place as we’ve brought here a selected list of Selenium interview questions and answers. These are the latest and most frequently asked questions by top multinational IT companies.

Our team has collected these questions after making repeated queries to several participants who were recently interviewed. With their inputs and our research, we were able to deliver this post with the most relevant Selenium interview questions.

Also, the readers who read our Selenium Webdriver tutorials and attempted the ultimate Selenium quiz had requested us for a comprehensive list of Selenium interview questions. And some of them asked to cover a variety of questions on the application of Selenium.

Hence, we targeted three core areas (given below) which the recruiters refer the most to ask questions from you.

Table of Content.

  1. Latest Selenium Questions and Answers.
  2. Top WebDriver Interview Questions and Answers.
  3. General Framework Interview Questions and Answers.

A list of top frequently asked Selenium interview questions and answers are given below.

Top Selenium Interview Questions & Answers.

Selenium Interview Questions for Web Test Automation

Selenium Interview Questions for Web Test Automation

First of all, let’s go through some of the most basic questions that are asked during Selenium interviews.

Basic Selenium Interview Questions for Web Automation.

Question-1: What is Selenium and what are its popular versions?


Selenium is the most popular testing tool for web-based UI automation. It exposes a set of APIs which support multiple platforms (e.g. Linux, Windows, Mac OS X, and so on). Also, all modern browsers likes of Google Chrome, Mozilla Firefox, Internet Explorer, and Safari can be used to run Selenium tests. And it also covers Android platform where Appium is the tool which implements Selenium Webdriver interface for mobile automation.

Notably, Selenium had three major releases apart from many subsequent minor ones. Here they are-

Selenium 1.0 or Selenium RC.

It was released in early 2004 and provided an API set which used a server to exchange commands and responses with the browsers.

Selenium 2.0 or Selenium Webdriver.

It came out in mid-2011 and introduced a set of the major enhancements in Selenium functionality. These new APIs completely replaced the server component and interacted natively with the target browsers.

Selenium 3.0.

This version was another big one that was released in late 2016. The main change it brought up is the W3C specifications of Webdriver APIs for browser automation. It is based on the philosophy that each major browser would provide its own implementation of Webdriver APIs.

Question-2: How do you start Selenium RC from the command line?


// Simple way to start Selenium RC is­

java -jar selenium-server.jar

// Run a suite of Selenese scripts in a browser

java -jar selenium-server.jar -htmlSuite

Question-3: On my machine port 4444 is not free. How can I use another port?


// You can specify port while running the selenium server as –

Java -jar selenium-server.jar –port 5555

Question-4: What is Selenium server and how does it differ from Selenium hub?


Selenium server is a standalone application for using a single server as a test node. Selenium hub acts as a proxy in front of one or more Selenium node instances. A hub + node(s) is called a Selenium grid. Running Selenium server is similar to creating a Selenium grid from a hub and a single node on the same host.

Question-5: How do you connect to Database from selenium?


Selenium is a Web UI automation tool. It doesn’t provide any API to establish a database connection. It’s up to the programming language which you are using with Selenium for automation. In the below example, we assume that Java is being used.

A Connection object represents a connection with a database. When we connect to a database by using connection method, we create a Connection Object, which represents the connection to the database. An application may have one or more than one connections with a single database or many connections with different databases.

We can use the Connection object for the following things:

  • It creates the Statement, PreparedStatement and CallableStatement objects for executing the SQL statements.
  • It helps us to Commit or roll back a JDBC transaction.
  • If you want to know about the database or data source to which you are connected then the Connection object gathers information about the database or data source by the use of DatabaseMetaData.
  • It helps us to close the data source. The Connection.isClosed() method returns true only if the Connection.close() has been called. This method is used to close all the connection.

Firstly we need to establish the connection with the database. This is done by using the method DriverManager.getConnection(). This method takes a string containing a URL. The DriverManager class attempts to locate a driver that can connect to the database represented by the string URL. Whenever the getConnection() method is called the DriverManager class checks the list of all registered Driver classes that can connect to the database specified in the URL.


String url = "jdbc: odbc: makeConnection";

Connection con = DriverManager.getConnection(url, "userID", "password");

Question-6: What are the locators available in Selenium RC?


  1. ID
  2. Name
  3. CSS (Cascade Stylesheet)
  4. XPATH (Relative XPath and Absolute XPath)
  5. Dom

Question-7: How do you verify an object present on multiple pages?


We can use the following Selenium command to check the object on each page.


Question-8: What is the difference between a single and double slash used in XPath?


If XPath starts selection from the document node, it’ll allow you to create ‘absolute’ path expressions.

e.g. “/html/body/p” matches all the paragraph elements

If XPath starts selection matching anywhere in the document, then it’ll allow you to create ‘relative’ path expressions.

e.g. “//p” matches all the paragraph elements

Question-9: How will you write a User Extension for Selenium IDE/RC?


User extensions are stored in a separate file that Selenium IDE or Selenium RC uses to activate the extensions. It comprises of function definitions which are written in JavaScript.

Because Selenium’s core is developed in JavaScript, creating an extension follows the similar standard rules for prototypal languages. To create an extension, we have to write a function in the following design format.

// sample
Selenium.prototype.doFunctionName = function(){


The “do” in front of the function name tells Selenium that this function can be called as a command for a step instead of an internal or private function.

Question-10: How do you verify the presence of an element after the successful page loading?


It can be achieved with the following line of code.

Just mention some time value to check the element (in seconds) like:

public void waitForElementPresent(String element, int timeout) throws Exception {
    for (int second = 0;; second++) {
        if (second >= timeout)
            fail("Timeout. Unable to find the Specified element" + element);
        try {
            if (selenium.isElementPresent(element))
        } catch (Exception e) {

Question-11: What do you know about Selenium Grid? What capabilities does it provide?


Selenium Grid is a tool that dramatically speeds up functional testing of web-apps by leveraging your existing computing infrastructure. It allows you to easily run multiple tests in parallel, on multiple machines, in a heterogeneous environment.

Based on the excellent Selenium web testing tool, Selenium Grid allows you to run multiple instances of Selenium Remote Control in parallel. Even better, it makes all these Selenium Remote Controls appear as a single one, so your tests do not have to worry about the actual infrastructure. Selenium Grid cuts down on the time required to run a Selenium test suite to a fraction of the time that a single instance of Selenium instance would take to run.

Question-12: How will you start the selenium server from your Java class?


try {

seleniumServer = new SeleniumServer();


} catch (Exception e) {



Question-13: What are the verification points available in Selenium?


There are largely three types of verification points available with Selenium –

  • Check for page title
  • Check for certain text
  • Check for certain element (text box, drop down, table etc.)

Question-14: What is XPath? When should you use XPath in Selenium?


XPath is a way to navigate in an HTML/XML document and this can be used to identify elements in a web page. You may have to use XPath when there is no name/id associated with an element on the page or only a partial part of name/id is constant.

Direct child is denoted with – /

Relative child is denoted with – //

Id, class, names can also be used with XPath –

  • //input[@name=’q’]
  • //input[@id=’lst-ib’]
  • //input[@class=’ lst’]

If only part of id/name/class is constant than “contains” can be used as –

  • //input[contains(@id,’lst-ib’)]

Question-15: What is CSS locator strategy in Selenium? Explain with example.


CSS location strategy can be used with Selenium to locate elements, it works using cascade style sheet location methods in which –

Direct child is denoted with – (A space symbol)

Relative child is denoted with – >

Id, class, names can also be used with XPath –

  • css=input[name=’q’]
  • css=input[id=’lst-ib’] or input#lst-ib
  • css=input[class=’lst’] or input.lst

If only part of id/name/class is constant than “contains” can be used as –

  • css=input[id*=’lst-ib’)]

Element location strategy using inner text

  • css = a:contains(‘log out’)

Question-16: There are many locators like id, name, XPath, CSS locator, which one should I use?


If there are unique names or identifier available then they should be used instead of XPath and CSS locators. If not then CSS locators should be given preference as their evaluation is faster than XPath in most modern browsers.

Question-17: What is the mechanism to handle multiple popups in selenium?


Multiple popups can be handled by using the command getWindowHandles().

Then store all the window names into Set<String> variable and transform it into an array.

Next, by using the array index, you can navigate to specific window by using


Question-18: How do you handle Ajax controls using selenium?


Let’s consider an example. Say the Google test box which is an Ajax control and when we enter some text into it, then it displays the auto-suggested values.

To work with such controls, you need to capture all the suggested values in a string after entering the value in the text box. Then, just split the string and take the values.

Back to top.

WebDriver Interview Questions and Answers.

Question-19: What are the advantages of Selenium Webdriver over Selenium RC?


Selenium RC’s architecture is quite complicated while WebDriver’s architecture is simpler than Selenium RC’s.

  • Though Selenium RC is slower since it uses an additional JavaScript program called Selenium Core. On the contrary, WebDriver is faster than Selenium RC since it speaks directly to the browser and uses browser’s own engine to control it.
  • Selenium Core, just like other JavaScript codes, can access disabled elements. Web Driver interacts with page elements in a more realistic way.
  • Selenium RC’s API set is already evolved but contains redundancies and often confusing commands. WebDriver APIs are simpler and do not contain any redundant or confusing commands.
  • Selenium RC cannot support the headless HtmlUnit browser. It needs a real, visible browser to operate on. Web Driver can support the headless HtmlUnit browser.
  • Selenium RC has built-in test result generator and it automatically generates an HTML file of test results. Web Driver has no built-in command that automatically generates a Test Results File.

Question-20: What is the primary difference between “GET” and “NAVIGATE” methods?


Get method will get a page to load or get page source or get the text that’s all. Whereas the navigate will guide through the history like refresh, back, forward.

For example – if we want to move forward and do some functionality and back to the home page.

This can be achieved by calling the <navigate()> method.

The driver.get() method will wait till the whole page gets loaded and driver.navigate() will just redirect to that page and will not wait.

Question-21: How is the implicit Wait different from Explicit wait?


Implicit Wait sets internally a timeout that will be used for all consecutive Web Element searches. It will try looking up the element again and again for the specified amount of time before throwing a NoSuchElementException if the element could not have been found. It does only this and can’t be forced into anything else – it waits for elements to show up.

Explicit Wait or just Wait is a one-timer used by you for a particular search. It is more extensible in the means that you can set it up to wait for any condition you might like. Usually, you can use some of the prebuilt Expected Conditions to wait for elements to become clickable, visible, invisible, etc., or just write your own condition that suits your needs.

Question-22: How will you handle alerts/pop-ups in Selenium WebDriver?


There are two types of alerts which are commonly referred.

  • Windows based alert pop ups
  • Web-based alert pop ups

Web-based alert pop-ups.

  1. WebDriver offers the users with a very efficient way to handle these pop-ups using Alert interface.
  2. void dismiss() – The dismiss() method clicks on the “Cancel” button as soon as the popup window appears.
  3. void accept() – The accept() method clicks on the “Ok” button as soon as the popup window appears.
  4. String getText() – The getText() method returns the text displayed on the alert box.
  5. void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

Windows based alert pop-ups.

Handling window based pop-ups have always been a little tricky as we know Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support Windows based applications and window alert is one of them.

  1. Robot class is a Java based utility which emulates the keyboard and mouse actions and can be effectively used to handling window based pop up with the help of keyboard events.
  2. The KeyPress and KkeyRelease methods simulate the user pressing and releasing a certain key on the keyboard respectively.

Question-23: How to take a screenshot with Selenium WebDriver?



WebDriver driver = new FirefoxDriver();


File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

// Now you can do whatever you need to do with it, for example copy somewhere

FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

Question-24: How can I address SSL Certificate issue in Firefox with WebDriver (or) how to manage the secured connection error in HTTPS?


FirefoxProfile profile = new FirefoxProfile();



driver=new FirefoxDriver(profile);

Question-25: How can I fix SSL certification issue in IE?


// Add the below command after opening the browser.


Question-26: What are the available locators in Selenium WebDriver?


  1. ID,
  2. Name,
  3. CSS,
  4. XPath,
  5. Class name,
  6. TagName,
  7. LinkText, and
  8. Partial Link Text.

Question-27: How can I handle AJAX controls in WebDriver?


AJAX stands for Asynchronous JavaScript and XML. It does not rely on the extra overhead of opening and closing tags that are needed to create valid XML. Most of the time WebDriver automatically handle the Ajax controls and calls. In case if it is not able to handle, you can follow the below way to handle.

//Waiting for Ajax Control

WebElement AjaxElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By. &lt;locatorType&gt;("&lt;locator Value&gt;")));

Question-28: How to perform Mouse over action on the sub menu item of a header menu?


With the actions object you should first move the menu title, and then move to the popup menu item and click it. Don’t forget to call actions.perform() at the end. Here’s some sample Java code:

Actions actions = new Actions(driver);

WebElement menuHoverLink = driver.findElement(By.linkText("Menu heading"));


WebElement subLink = driver.findElement(By.cssSelector("#headerMenu .subLink"));



Back to top.

General Framework Interview Questions and Answers.

Question-29: Can you broadly classify and compare the TDD, BDD and DDD frameworks?


You would have heard of all these acronyms buzzing all around. Here I’ll briefly explain them and tell how exactly they will help in the system test life cycle.

TDD – Test Driven Development.

It’s also called test-driven design, is a method of software development in which unit testing is repeatedly done on the source code. Write your tests watch it fails and then refactor it. The concept is we write these tests to check if the code we wrote works fine. After each test, refactoring is done and then the same or a similar test is performed again. The process is iterated as many times as necessary until each unit is functionally working as expected. TDD was introduced first by XP. I believe I have explained enough in simple terms.

BDD – Behavior Driven Development.

The behavior-driven development combines the general techniques and principles of TDD with ideas from domain-driven design. Its purpose is to help the folks devising the system (i.e. the developer) identify appropriate tests to write–that is, tests that reflect the behavior desired by the stakeholders.

DDD-Domain Driven Development.

DDD is about mapping business domain concepts into software artifacts. A DDD framework offers following benefits:

  • Helps the team to create a common model, between the business and IT stakeholders
  • The model is modular, extensible and easy to maintain as the design reflects the business model.
  • It improves the reusability and testability of the business domain objects.

Question-30: What is a Data-driven framework & how is it different from the Keyword Driven framework?


Data-driven framework.

In this framework, test case logic resides in Test Scripts. Test Data is separated and kept outside the Test Scripts. Test Data is read from the external files (Excel File) and are loaded into the variables inside the Test Script. Variables are used both for Input values and for Verification values.

Keyword Driven.

The keyword/table driven framework requires the development of data tables and keywords. They are independent of the test automation tool used to execute them. Tests can be designed with or without the Application. In a keyword-driven test, the functionality of the Application-under-test is documented in a table as well as in step-by-step instructions for each test.

Question-31: Explain the advantages of using TestNG over JUnit framework?


Advantages of TestNG over Junit.

  1. In JUnit, we have to declare @BeforeClass and @AfterClass. It is a constraint in JUnit whereas in TestNG there is no constraint like this.
  2. Additional Levels of setUp/tearDown level are available in TestNG.
    1. @ Before/AfterSuite
    2. @Before/AfterTest and
    3. @Before/AfterGroup
  3. There is no need to extend any class in TestNG.
  4. There is no method name constraint in TestNG as in JUnit.
  5. In TestNG, we can tell the test that one method is dependent on another method whereas in JUnit this is not possible.
  6. Grouping of test cases is available in TestNG whereas the same is not available in JUnit. Execution can be done based on Groups. For example, if you have defined many cases and segregated them by defining 2 groups as Sanity and Regression. And if you only want to execute the “Sanity” cases then just tell TestNG to execute the “Sanity”. TestNG will automatically execute the cases belonging to the “Sanity” group.
  7. Also, TestNG supports parallel test case execution.

Question-32: What is the purpose of TestNG Parameters which are related to @Test annotation?


In TestNG, Parameters are keywords that modify the annotation’s function. You can read more about parameters from the TestNG tutorials section on our blog.

Question-33: Can we run a group of test cases using TestNG?


Yes, TestNG framework supports to execute multiple test cases with the help of test groups.

It provides the following options to run test cases from a specific group.

If you want to execute the test cases based on one of the groups like regression test or smoke test-

@Test(groups = {“regression-tests”, “smoke-tests”})

Question-34: Which WebDriver implementation claims to be the fastest and why?


The fastest and a lean implementation of WebDriver is the HTMLUnitDriver.

The simple reason is that the HTMLUnitDriver does not execute tests in the browser. Instead, it uses a plain HTTP request-response mechanism for running test cases.

This approach is far quicker than launching a browser for test execution.

Question-35: Is it possible to use Selenium RC API with Selenium 2.0?


Yes, you can emulate Selenium 1.0 API (i.e. RC) with Selenium 2.0. But not all of the Selenium 1.0 methods are supported.

To achieve this you need to get Selenium instance from WebDriver and use Selenium methods.

Method executions might also be slower while simulating Selenium 1.0 within Selenium 2.0.

Question-36: Can you use Selenium Grid with Java, Dot Net or Ruby?


  • With Java, you can take advantage of parallel testing capabilities of TestNG to drive your Selenium grid tests.
  • With .Net, you can use “Gallio” to execute your tests in parallel.
  • With Ruby, you can use “DeepTest” to distribute your tests.

Note: You can learn more about Selenium from

Back to top.

Summary – Selenium interview questions and answers.

Finally, a ton of thanks to you as you’ve invested your time to read this post and visit our blog. We wish that the above set of Selenium interview questions will certainly help you to boost confidence. But there is more to the Selenium automation story which we’ll bring in our coming Selenium tutorials.

However, if you liked this post, then please do circulate it within your friend circle or on any social media platform of your choice.

Enjoy reading and keep visiting!




  1. Harshal
    • Meenakshi Agarwal
  2. Gopika
  3. Geeta
    • Meenakshi Agarwal
  4. satishPatil
    • Meenakshi Agarwal
  5. Selenium Actions Class for Handling Keyboard and Mouse Events
  6. krishna
    • Meenakshi Agarwal
  7. Smitha
    • Meenakshi Agarwal
  8. Pravalika
    • Meenakshi Agarwal
  9. Vikrant
    • Harsh S.
  10. rajendra
    • Meenakshi Agarwal