Top Answers to Selenium Interview Questions

1. What is automation testing?

Automation testing is the process of automating the manual testing of application under test or system under test. It includes the involvement of testing tools that helps us create test scripts which can be used repeatedly without any human intervention.

2. Is Selenium 2.0 different from Selenium 3.0? If so, how?

Selenium RC is called Selenium 2.0, and the integration of Selenium RC and WebDriver as a single tool has formed Selenium 3.0.

3. Mention some of the popular tools for automation testing.

  • Selenium
  • Rational Robot
  • HP UFT
  • IBM Rational Functional Tester


Watch this Selenium Tutorial for Beginner

Top Selenium Interview Questions and Answers Interested in learning Selinum? Click Here

Learn for free ! Subscribe to our youtube Channel.

4. What is a locator? How will you locate an element using Selenium?

Selenium uses locators to find and match the elements of our page that it needs to interact with. There are different types of locators to identify web elements in our web page:

  • Identifier
  • ID
  • Name
  • Link
  • DOM
  • XPath
  • CSS
  • UI element

5. What are the test types that are supported by Selenium?

For testing the web-based applications, Selenium can be used.

The test types supported by Selenium are:

a) Functional

b) Regression

A. Functional testing authenticates that each function of the software application performs in accordance with specific requirements. This testing primarily involves black box testing, and it is not concerned about the source code of the application.

B. Regression testing is nothing but a full or partial selection of the already executed test cases which are re-executed to ensure whether the existing functionalities work fine.

Learn more about Selenium in this insightful blog on How To Test Web Application Using Selenium!

6. What is XPath?

While DOM is the recognized standard for navigating through an HTML element tree, XPath is the navigation tool used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize, and transport arbitrary data. It stores data in a keyvalue pair which is very much similar to HTML tags. Both being markup languages and falling under the same umbrella, XPath can be used to locate HTML elements.

The fundamental concept behind locating elements using XPath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

7. Explain the difference between single slash and double slash in XPath.

Single Slash (/): Single slash is used to create an XPath with an absolute path. In this case, the XPath would start selection from the document’s start node. 

Double Slash (//): Double slash is used to create an XPath with a relative path. In this case, the XPath would start selection from anywhere within the document.

8. Why should I use Selenium for test automation?

Selenium should be used for test automation because it:

  • Is a free and open-source tool
  • Has a large user base and helps communities
  • Has cross-browser compatibility (Firefox, Chrome, Internet Explorer, Safari, etc.)
  • Has great platform compatibility (Windows, Mac OS, Linux, etc.)
  • Supports multiple programming languages (Java, C#, Ruby, Python, Perl, etc.)
  • Has fresh and regular repository developments
  • Supports distributed testing


9. Does Selenium have any technical limitations? If so, what are those limitations?

Yes, Selenium has a few limitations:

  • The testing of only web applications are possible using Selenium.
  • Testing of mobile applications or desktop applications is not possible.
  • Captcha and barcode readers cannot be tested using Selenium.
  • A third-party tool like TestNG or JUnit should be used to generate reports. 
  • As Selenium is a free tool, there is no ready vendor support through which users can find various helping communities.
  • Prior programming language knowledge is expected from users.

Click here to know more about Selenium, in this Selenium course.

10. What is an object repository?

An object repository allows testers to accumulate web elements of the application under test (AUT), along with their locator values, in one or more centralized locations as restricted to hard-coding them within the test scripts.

11. What are the different types of annotations used in Selenium? Explain the JUnit Annotation linked with Selenium.

In Java, a special form of syntactic metadata can be added to Java source code, which is known as Annotations. Variables, parameters, packages, methods, and classes are annotated. Some of the JUnit Annotations are:

  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith

JUnit Annotations linked with Selenium are:

  • @Test

The annotation @Test finds that a method is a test method. When used before a test method, it is mentioned as @Test; it informs the JUnit framework that the following method is a test method.

  • @Before

The @Before annotation is used to find the method which is executed before executing the test method. This method can be used to set up the test environment.

  • @After

The @After annotation is a method that is executed after executing the Test Method. This method can be used to do teardown, i.e., it is a method used to delete all temporary data, set up default values, clean up test environment, etc.

  • @BeforeClass

The @BeforeClass method is used only once before the start of all tests. Basically, this is used to perform cumbersome activities, like connecting to a database.

  • @AfterClass

The @AfterClass method is used only once after executing all tests. Basically, this is used to carry out clean-up activities, like disconnecting from a database.

12. Why do testers choose Selenium over QTP?

 Selenium is more widely used than QTP as:

  • Selenium is an open-source tool whereas QTP is a profitable tool
  • Selenium is used specifically for testing web-based applications, while QTP can be used for testing clientserver applications too.
  • Selenium supports multiple browsers like Firefox, IE, Opera, Safari, etc. and has multiple operating systems compatibility too. Supported OS platforms are Windows, Mac, Linux, etc. Whereas, QTP is limited to Internet Explorer on Windows.
  • Selenium supports multi-programming language compatibility. Languages supported are Python, Ruby, Perl, etc. Whereas, QTP supports only VBScript.

These are described in Selenium’s online reference guide and on Selenium community

13. What are the four elements you have to pass in Selenium?

Four parameters that need to be passed in Selenium are:

  • Host
  • Port number
  • Browser
  • URL

14. What is the same-origin policy? How can I avoid the same-origin policy?

The ‘Same-origin Policy’ is introduced for security reasons.

  • It ensures that the content of our site will never be accessible by a script from another site. 
  • As per the policy, any code loaded within the browser can only operate within that website’s domain.

To avoid this same-origin policy, the proxy injection method is used. In the proxy injection mode, Selenium Server tricks the browser to be a real HTTP URL, i.e., it acts as a client-configured HTTP proxy, which sits between the browser and the application under test (AUT) and then masks the AUT under a fictional URL.


15. What are data-driven framework and keyword-driven framework?

A data-driven framework in Selenium is an approach of separating a ‘dataset’ 

from the actual ‘test case’ (code). This framework is completely dependent on the 

input test data. The test data is inserted from external sources such as an excel 

file, CSV file, or any database.

It also allows us to easily control how much data needs to be tested. We can 

easily increase the number of test parameters by adding more username and 

password fields to the excel file (or other sources).

A keyword-driven framework is an extension to data-driven testing framework in the sense that it not only isolates the test data from the scripts but also keeps the particular section of code belonging to the test script in an external data file. These sets of code are known as keywords, and hence the framework is so named. Keywords are self-guiding and work based on what actions need to be performed on the application.

16. How will you use Selenium to upload a file?

If the file is on the same machine or in a mapped network drive, it is really straightforward: We need to type the ‘path’ of the file in the FileUpload control. For example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")

Learn more about Selenium in Selenium tutorial.

17. What is the difference between getwindowhandles() and getwindowhandle()?

getwindowhandles(): It is used to get the address of all open browsers, and its return data type is Set<String>.

getwindowhandle(): It is used to get the address of the current browser where the control is, and its return type is a string data type.

18. What is Selenese and what are the three types of Selenese?

Selenese is a set of commands in Selenium used for running a test. 

The three types of Selenese are as follows:

  • Actions: They are used for performing the interactions and operations with the target elements.
  • Accessors: They are used for storing values in a variable.
  • Assertions: They are used as a checkpoint.

19. If I want to insert a breakpoint in Selenium IDE, how can I do that?

To insert a breakpoint:

  • First, we’ll have to select ‘Toggle Breakpoint’ by right-clicking on the command in Selenium IDE.
  • Then, press ‘B’ on the keyboard and select the command.
  • At this moment, a breakpoint can be set just before the test case you need to examine.
  • Now, click on the ‘Run’ button to run the test case from the starting point to the breakpoint.
  • The same step should be repeated for deselecting a breakpoint.

20. How do I launch the web browser using WebDriver?

The following syntax can be used to launch the browser corresponding to the system’s operating system:

  • WebDriver driver = new FirefoxDriver();
  • WebDriver driver = new InternetExplorerDriver();
  • WebDriver driver = new ChromeDriver();

21. What are the different types of waits available in WebDriver?

There are two types of waits available in WebDriver:

  • Implicit wait
  • Explicit wait

Implicit wait: These waits are used to provide a default waiting time (say, 30 seconds) between consecutive test steps across the entire test script. Hence, the subsequent test step would only be executed when the 30 seconds have elapsed after executing the previous test step.

Explicit wait: These waits are used to halt the execution until a particular condition is met or the maximum time has elapsed. Explicit waits are instantiated for a particular instance only, whereas, implicit waits are not.

22. How do I handle a frame in WebDriver?

An iframe (acronym for ‘inline frame’) is used to insert another document within the current HTML document.

Select iframe by ID

driver.switchTo().frame(“ID of the frame“);

Locating iframe using tagName


Locating iframe using index


frame(“Name of the Frame”)

driver.switchTo().frame(“name of the frame”);

frame(WebElement element)
Select Parent Window


Go through the Selenium Course in London to get clear understanding of Selenium.

23. How do I set the test case priority in TestNG? Setting Priority in TestNG:

Code Snippet

Test Execution Sequence:

  1. Method1
  2. Method2
  3. Method3

24. What are the different types of frameworks?

The different types of frameworks are as follows:

  • Module-based Testing Framework

This framework divides the entire ‘application under test’ into a number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts are taken together it builds a larger test script representing more than one module.

  • Library Architecture Testing Framework

Instead of dividing the application under test into test scripts, with this framework, we segregate the application into functions or rather common functions that can be used by the other parts of the application as well. Thus, we create a common library constituting of common functions for the application under test. Therefore, these libraries can be called from the test scripts whenever required.  

  • Data-driven Testing Framework

The data-driven testing framework helps us segregate the test script logic and the test data from each other. It lets us store the test data into an external database. The data is conventionally stored in ‘keyvalue’ pairs. Thus, the key can be used to access and populate the data within the test scripts.

  • Keyword-driven Testing Framework

The keyword-driven testing framework is an extension to the data-driven testing framework in the sense that it not only segregates the test data from the scripts but also keeps a certain set of codes belonging to the test script in an external data file.

  • Hybrid Testing Framework

Hybrid testing framework is a combination of more than one above-mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks.

  • Behavior-driven Development Framework

The behavior-driven development framework allows the automation of functional validations in an easily readable and understandable format to Business Analysts, Developers, Testers, etc.

25. Describe the difference between Selenium and QTP.

FeatureSeleniumQuick Test Professional (QTP)
Browser CompatibilityIt supports almost all popular browsers like Firefox, Chrome, Safari, Internet Explorer, Opera, etc.QTP supports Internet Explorer, Firefox, and Chrome. It only supports Windows operating system.
DistributionIt is distributed as an open-source tool and is freely available.It is distributed as a licensed tool and is commercialized.
Application Under TestIt supports testing of  web-based applications only.It supports testing of both web-based and Windows-based applications.
Object RepositoryObject repository needs to be created as a separate entity in Selenium.QTP automatically creates and maintains object repository.
Language SupportIt supports multiple programming languages like Java, C#, Ruby, Python, Perl, etc.It supports only VBScript.
Vendor SupportAs Selenium is a free tool, users would not get the vendor’s support in troubleshooting issues.Users can easily get the vendor’s support in case of any issue.

Learn more about Selenium in this Selenium training in New York to get ahead in your career!

26. In Selenium, what are breakpoints and start points?

Breakpoints: Breakpoints are used to stall the execution of the test. The execution will stop whenever a breakpoint is implemented, and this will help us check whether the code is working properly or not.

Start points: Start points are the points from where the execution should begin. Start points can be used when we want to run the test script from the middle of the code or a breakpoint.

27. Mention the need of session handling while working with Selenium.

While working with Selenium, we need session handling. This is because, during test execution, Selenium WebDriver has to interact with the browser all the time to execute the given commands. It is also possible that, before the current execution completes, someone else starts the execution of another script in the same machine and in the same type of browser. So to avoid such a situation, we need session handling.

28. Mention the types of Listeners in TestNG.

The types of Listeners in TestNG are:

  1. IAnnotationTransformer
  2. IConfigurable
  3. IConfigurationListener
  4. IExecutionListener
  5. IHookable
  6. IInvokedMethodListener
  7. IInvokedMethodListener2
  8. IMethodInterceptor
  9. IReporter
  10. ISuiteListener
  11. ITestListener

29. How can you handle Windows-based popups with Selenium?

Selenium solely supports web application testing. It does not support the testing of Windows-based applications or mobile applications. To handle Windows-based popups, third-party intervention is required. AutoIT and Robot Class are examples of third-party tools that we can use alongside Selenium to handle Windows-based popups.

Interested in learning Selenium? Click here to learn more in this Selenium Training in Sydney!

30. For database testing in Selenium WebDriver, what API is required?

For database testing in Selenium WebDriver, we need the JDBC (Java Database Connectivity) API. It allows us to execute SQL statements.

31. How can you identify an object using Selenium?

We can use isElementPresent (string locator) to find an object using Selenium. It takes a locator as the argument and, if found, returns a Boolean.

Become Master of Selenium by going through this online Selenium course in Toronto.

4 thoughts on “Top Selenium Interview Questions and Answers”

  1. With this Interview Q and A. I come to know some technical tips on Selenium. It will be very helpful for my interview preparation.

  2. I like the questionaire. It summarises well what questions and key points that both employers and emplyees need to know.
    Thanks for sharing that.

Leave a Reply

Your email address will not be published. Required fields are marked *

Interview Questions