Saturday, May 25, 2024
HomeEducationSelenium Interview Questions and Answers in 2022

Selenium Interview Questions and Answers in 2022

Selenium Java Interview

This blog will guide you through the important Selenium Interview Questions. The sole purpose is to help you brush up and ace the interview like a pro. But, before we jump into these questions, let’s understand it from the roots.

  1. Selenium Testing and Automation Testing Interview Questions
  2. Basic Selenium Interview Questions for Freshers
  3. Selenium Interview questions for Experienced Professionals
  4. Selenium Webdriver Interview Questions
  5. Frequently Asked Questions on Selenium

The crucial phase in the software development life cycle (SDLC) is Testing. There are two types of Testing.

  1. Manual Testing
    • It involved the physical execution of test case scenarios against the applications to detect the errors and bugs.
    • This posed a lot of challenges and heavy manual effort.
  2. Automation Testing
    • On the other hand, Automation Testing provided us a way to automate the testing processes and increased the demand.

In midst of all this, questions do arise like What is Selenium? Why is it important and so on?

Selenium is an open-source, automated testing tool that is used to test web applications across various browsers. However, the sad part is, it can test only web applications and not mobile and desktop applications.

Some of the leading browser vendors adopted Selenium as the essential part of their browser and thus leading to an increase in high demand for this.

The entire set of Selenium interview questions includes two sections.

If you all are geared up, we shall dive into the most asked interview questions on Selenium.

Selenium Testing and Automation Testing Interview Questions

1. What is Automation Testing?

The use of automation tools for writing and executing the test cases with no manual involvement for executing the Automated Test Suite is called Automation Testing. The Automation tools are preferred by Testers to write the test cases or test scripts and then group them all into Test Suites. These tools are designed to execute manually designed test cases without any human intervention. 

2. What are the advantages/benefits of Automation Testing?

This is one of the common interview questions. Some of the advantages of Automation Testing include:

  • Save Money and Time. 
  • Automation Testing increases the accuracy as there is no chance for human errors.
  • Code Reusability. Create once and execute multiple times with Less or no maintenance.
  • Easy Reporting. Automatically generates the reports after the execution of the test cases.
  • Easy for Compatibility Testing by enabling the parallel execution in combination with OS and browser environments.
  • More Reliable, Powerful and Versatile.
  • Automation Tools allows us to integrate with the Jenkins, GitHub etc.,
  • Mostly used for Regression Testing.
  • Helps to monitor the Test Coverage and increase the test cases accordingly.

3. How many Test cases have you automated per day?

This is one of the tricky Selenium interview questions. Actually, it depends on the complexity and length of the Test case scenario. When the complexity is limited, you can automate two to five test cases and one or fewer test cases when the complexity is high in a day.

Our Most Popular Free Courses:

Basic Selenium Interview Questions for Freshers

4. What is Selenium?

Selenium is one of the most popular automated Testing Suite. It’s a playback tool to perform functional testing without any knowledge of a test scripting language. Selenium is the open-source, web UI-based automation testing suite. Jason Huggins developed this tool in 2004 at ThoughtWorks. 

5. What are the different Selenium suite Components?

Selenium is not just a single tool or utility, rather a package of several testing tools and that’s why it’s called Selenium Suite. Each of these tools caters to different testing and testing environments.

It comprises four major components as follows,

  1. Selenium Integrated Development Environment (IDE):

It is distributed as a Firefox plugin that acts as a record and playback tool. It is developed to speed up the creation of automation scripts.

  1. Selenium Remote Control (RC):

Selenium Remote Control is a server with which the user can create the Test cases in any desired programming language. The commands present in the test scripts are accepted by the server and sent to the browsers as the Selenium core Java script commands to maintain the browser behavior accordingly.

  1. Selenium Web driver:

Selenium Web Driver is a programming interface to create and run test cases. It provides a way to act on various web elements. This Web driver does not require another server, unlike Selenium Remote Control.

  1. Selenium Grid:

The Selenium Grid is used to distribute the commands to the different machines simultaneously. It paves a way for the parallel execution of the test cases in different browsers and different environments. It achieves concurrency and integrity in the Test Suite Execution.

6. Why should I use Selenium?

  • Open-source
  • Large support from the community and the user base is huge
  • Cross-browser compatibility (Firefox, Chrome, Edge etc.,)
  • Multiple programming language support (Python, Java, Perl etc.,)
  • Every day or regular repository developments
  • Distributed Testing is also supported.

7. What is the major difference between Selenium 3.0 and Selenium 2.0?

Selenium 2.0 represents the merger of the Original Selenium project with the Web Driver project. The Selenium RC got deprecated but was used for backward compatibility.

Selenium 3.0 often called an extension of the Selenium 2.0 is inherently backward compatible with increased stability and several bug fixes and does not involve the Selenium RC at all.

8. What do you mean by Selenese?

Selenese which is called the Selenium command is the set of the selenium commands that run your test cases. For example, open (URL) is a Selenium command which opens the specified URL in the specific browser. A test script is the sequence of all these commands put together. There are three types of Selenese. They are,

  1. Actions: We can use it to perform interactions and operations on the target elements
  2. Accessors: These are used for storing the values in the variables.
  3. Assertions: These can be used as checkpoints to keep track of the sequential flow of commands.

9. How many parameters do selenium commands have at a minimum?

There are four parameters that you must pass in Selenium. They are as follows,

We can bind the Selenium to a specific IP address instead of a Local host in our local machine.

  • Port Number

We can specify the port number too i.e., TCP/IP port to connect the Selenium tests to the Grid hub. We need to make sure that there is no other application with the same port number up in any other location within the same machine.

The browser in which the selenium scripts have to be executed.

The application URL triggers the test cases within that.

10. What is the difference between Absolute path and Relative Path?

Absolute Path: 

  • This path starts from the root node and ends with the desired elements node.
  • It starts with a single slash (/)
  • Example: /html.body/div/td/input

Relative Path:

  • This path starts from any node in between and to the desired elements node.
  • It starts with a double slash (//)
  • Example: //input/example[@id=name]

11. What is the difference between Assert and Verify statements in Selenium?


  • We can check whether an element is on the page or not.
  • The test fails and gets terminated whenever there is a fail in the check. That is the program control flow stops.


  • It’s only to specify whether the given condition is true or false.
  • The program control flow does not stop due to this.

Overall, the Verify statement does not halt the program execution whereas the Assert statement does halt the execution. 

12. What is the difference between findElement() and findElements()?

findElement() : 

It uses the given locating mechanism to find the first element within the current page and return a single web element.


It also uses the given locating mechanism to find all the elements within the current page and return the list of all web elements.

13. What are the verification points that are available in Selenium?

  • Selenium IDE: Verify and Assert commands
  • Selenium Web Driver: This does not have any built-in features for verification and always depends on our coding style. Some examples can be like checking the page title, checking for certain text in the page, checking for a certain element like textbox, dropdown, field etc.,

14. Explain Implicit wait, Explicit wait and Fluent wait?

  • Implicit wait:

We can set the timeout for a specific amount of time for all the successive web elements. In this specified time, the web driver searches for all the web elements before throwing the NoSuchElementException. 

  • Explicit wait:

We can tell the Web Driver to wait for certain conditions before throwing the ElemntNotVisibleException.

  • Fluent wait:

It’s a slight extension for the explicit wait. Apart from waiting for certain conditions to be met, we can also set the frequency with which we check the condition before throwing the ElementNotVisibleException.

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


It’s a command by which the current window can be closed. For example, if we have multiple browser windows open then, by using this command we can close the window with which the focus is.


This command closes all the browser windows which are open. For example, if we have multiple browser windows open then, this command can close all the windows at once.

16. Can Selenium handle windows-based pop-up?

As we already know that Selenium is an automation testing tool that can work with only web applications. Therefore, the pop-up in windows cannot be handled by Selenium. But, by integrating with the third-party tools we can overcome this problem.

17. What is an Object Repository and Explain how we can create the Object Repository in Selenium?

The collection of web elements that belongs to the application under test along with their locator values. This is often referred to as Object Repository. The only thing is the locators are stored in a centralized location than hard coding them in the test scripts.

While coming to Selenium, the objects can be stored in Excel also and can be used to populate them in the script whenever required. 

18. What are the different kinds of frameworks?

  • Data-driven framework:

The test data of this kind is generated from external files like excel, CSV, XML, etc. The data relating to the test cases rely outside on the input and verification values maintained using the variables.

  • Keyword-driven framework:

The data tables and the keywords are developed independently of the automation test cases. In this framework, the functionality of the test scenarios is documented in the table step by step.

  • Module-based testing framework:

Isolated and Logical modules are made out of the application that is under test. Independent test scripts are written for each module. These scripts are then clubbed together as a whole.

  • Behaviour driven testing framework:

The test scripts are written in such a way that the automation is done on the functionality or features to ensure the readability, understanding, and reliability to either the business experts or developers, or other testers.

  • Hybrid testing framework:

The combination of more than one of the above-mentioned frameworks by leveraging the benefits of each is called a Hybrid testing framework.

19. What is the same-origin policy? How can we avoid it?

This policy is introduced for security reasons.

  • By this policy, it ensures that we cannot access the script from another site.
  • The source code which is loaded within the browser can only be operated within that website’s domain.
  • This policy can be avoided by using the proxy-injection method. In this method, the browser is tricked using the Selenium’s server to be a real URL (fictional URL).

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

getwindowhandles(): This is used to get the address of all the open browsers and returns the data type of Set<String>.

getwindowhandle(): This is used to get the address of the current browser window where it’s focused on and returns the data type of String.

21. What are the different types of Annotations used in Selenium?

Syntactic metadata can be added to the Java source code which is known as annotations. They can be added on variables, parameters, packages, classes etc., Some of them which are used in Selenium include,

@Before, @Test, @After

22. What is the difference between setSpeed() and sleep() methods?

These methods will delay the speed of the execution. 

Thread.sleep(): The current thread will stop for a specified period of time. It only waits once when the command is given. It takes only a single argument that is Integer format.

set sleep(): This command will stop the execution for every selenium command. This command is used only for demonstration purposes and also for a slow web application.

23. List the advantages of Web driver over Selenium server?

  • If Selenium web driver is used, then no need to use the dependency of the selenium server.
  • Selenium server provides us with the functionality of Selenium RC for the backward compatibility.
  • Selenium server acts as a middleware for the communication between browsers and the application. Whereas, the Selenium web driver directly calls the browser to support automation.

Our Most Popular Free Courses:

Selenium Interview Questions for Experienced Professionals

24. How can you store a value in a text box?

A command which can store the value from the text box using a web driver.

For example, 

driver.findElement(“your Textbox”)).sendKeys(“your keyword”);

25. How can you debug the tests in the Selenium IDE?

  • We need to first insert the breakpoints where we need to debug and execute the test step by step. 
  • Later, Run the test case.
  • After this, the execution stops at the point where the breakpoint is kept.
  • You can click on the Run button to continue the execution of all the commands sequentially.

26. What are regular expressions and How can you use regular expressions in Selenium?

The Search patterns are represented using the special Text string called the regular expressions. Regexp is the keyword that can be used as a prefix to treat a text in Selenium as a regular expression.

27. How can you handle working with multiple windows in Selenium?

selectWindow() command in Selenium can be used to switch among the working windows. The distinguishing factor among all the windows is the title of the window.

28. How can the message in the alert box be retrieved?

storeAlert() command can be used to retrieve the message from the alert pop-up and store it in a variable.

29. How can you verify the specific position of a web element?

verifyElementPositionLeft and verifyElementPositionTop commands are used. These use the pixel comparison by identifying the position of the element from the left and top of the web page respectively.

30. Why do we use Selenium RC?

  • Selenium IDE has the limitations which Selenium RC can diminish in terms of browser support and language support.
  • IDE does not support many functions like Logging, iterations, conditional statements, test case results reporting etc., as it supports only HTML Language.
  • That’s why the Selenium RC is used to communicate with the other languages like Perl, Python etc.,

31. What are the advantages or Benefits of Selenium RC?

Advantages or Benefits of RC include,

  • Data can be read or write to or from .xlsx, .csv, .txt etc.,
  • Dynamic objects and Ajax based UI elements can be handled.
  • Conditional statements and Iterations functionalities can be used to improve and enhance performance and flexibility.
  • Support for any programming languages and Operating systems.
  • Selenium RC can be used on any browser which is enabled with Java script.

32. Can you list the Technical limitations while using the Selenium RC?

  • Same origin policy
  • Anything outside the browser is also restricted to access in the test scenario execution.

33. What is the need to use the TestNG with Selenium RC?

If the requirement of the automation test suite is supposed to work against the different servers and client platforms then, we need to invoke the test cases from the command line. Also, we do need the test case results reports periodically to make estimates and also implement the flexibility on how to create the tests. Such kind of flexibility is provided by the TestNG.

34. Which Language do you use to implement test case suites in Selenium?

The most preferred language to implement Selenium is Python over Java. This is because,

  • Java programs do run slower when compared to the Python programs.
  • The implementation and the complexity of both are quite different and Python works well.
  • Python is dynamically typed whereas Java is statically typed.
  • Java is not simpler and compact to write test cases when compared to python.

35. What are Breakpoints and Start points in Selenium?

  • Break points:

The flow of execution is stopped using the breakpoints. By doing this we can verify that the code is working in an expected manner or not.

  • Start points: 

The point from where the execution should begin is determined by the start points. When you want to run a test script from the middle of the code or a breakpoint, we use these.

36. How is the desired capability useful in terms of Selenium?

A series of key-value pairs can be used to store information like the browser name, browser version, the path of the browser driver in the system, etc., to determine the behavior of the browser at the run-time. This feature or functionality is commonly referred to as desired capability.

For Selenium,

The driver instance can be configured using this.

It comes into practice when you want to run the test cases in different operating systems, browsers, and versions.

37. When do you use AutoIT?

As we already know that Selenium is used only to automate web applications. But if we want to handle or manage or maintain the GUI, HTML pop-ups then, we need the use of AutoIT.

38. Can you mention why do you need the Session handling in Selenium?

Session handling is very important while working with Selenium. This is because while working with the test case scenarios we need to establish the communication between the browser and the application while executing the commands. There can be an issue where while running a particular test script, another test script can be triggered within the same host and same type of browser. This is the most important part and the reason why we need the session handling.

39. Can you automate CAPTCHA?

The answer is No. We cannot automate CAPTCHA in Selenium. The concept of CAPTCHA is to ensure that the bots or automated test scripts should not have access to sensitive information, and that is why we cannot automate it. The captcha should be manually typed in order to continue the flow of execution of the test suite.

40. How do we launch different browsers in Selenium?

  • A driver instance should be created for a particular browser which we need to work upon. 
  • WebDriver driver = new FireFoxDriver();
  • WebDriver driver = new ChromeDriver();
  • Here, the WebDriver is the interface where the Firefox, chrome and all other browser driver implementations are made.

41. What is Locator and How do you locate an element in Selenium?

The elements of the web page are found and matched using locators to interact with. There are different kinds of locators to identify different types of elements on the web page. They are as follows,

  • ID
  • Name
  • Class
  • Partial Link
  • XPath
  • CSS Selector
  • Link Text

42. Why do you choose Selenium over QTP (Quick Test Professional)?

Feature Selenium Quick Test Professional (QTP)
Browser Compatibility Almost all popular browsers are supported. Firefox, Chrome, Safari, Internet Explorer, Edge, etc. This supports only Chrome, Firefox, and Internet explorer. Also, it supports only the Windows operating system.
Distribution Distributed as open-source and it is freely available. Distributed as a licensed tool and is commercialized.
Application Under Test (AUT) Web-based applications are only supported in this kind of automated testing. This provides support for both webs- based as well as windows applications for automated testing.
Object Repository The separate entity in Selenium is used to create the object repository. Automatic creation of the Object repository happens and is maintained too
Language Support Multiple Programming languages like Java, Python, Perl, Ruby, C#, etc., are supported by this Selenium. Only VBScript language is supported by this QTP.
Vendor Support As we already know that Selenium is a free tool, we do not get vendor support in troubleshooting the issues we face. Vendor support is guaranteed for the users using the QTP and they do get quick responses as QTP is commercialized and licensed.

Selenium Webdriver Interview Questions

43. What are the challenges and Limitations of the Selenium Web Driver?

As we all know that the Selenium Web Driver is used to mimic the real user actions on the web in the browser. Some of the challenges of Selenium are as follows,

  1. Not compatible to test the Windows or Desktop applications.
  2. Also, cannot be used to test the Mobile applications.
  3. No Built-in reporting and it must be integrated with the other tools to obtain the reports.
  4. Support for Image Testing is limited.
  5. The user should have prior programming knowledge.
  6. Since it is open-source, there is no vendor support.

44. What are the Testing types that are supported by Selenium?

Regression Testing and Functional Testing are majorly supported by Selenium.

  1. Regression Testing:

All the Test cases are executed repeatedly either partially or as a full to ensure that the existing functionalities are working as designed. It includes the following steps,

  • Re-testing: All the test cases in the Test Suite are executed which proves to be time-consuming and expensive.
  • Regression Test case Selection: The test cases are classified or categorized as features tests, integration tests etc., and some test cases are selected.
  • Prioritization of Test cases: The test cases that are selected are prioritized based on the critical functionalities and business impact.
  1. Functional Testing:

In this, all the functions in the application are verified with a specific requirement. This is primarily the black-box testing as it is not concerned about the source code of the application. It includes the following steps,

  • Test Input is identified.
  • Test Outcome is computed.
  • The test case is executed
  • The actual outcome and the test outcome are compared accordingly.

45. Explain different types of Exceptions in Selenium Web driver?

The Exceptions in the Selenium web driver are also similar to the exceptions in any other programming language like Java, C#, etc., Some of the most common exceptions are as follows,

  • TimeOutException: This exception can be thrown when a particular operation cannot be completed in a specified or stipulated time.
  • NoSuchElementException: When an element in the given set of attributes is not present on the web page then, this exception can be thrown.
  • ElementNotVisibleException: There can be cases where a particular element can be present in the DOM (Document Object Model) but not visible on the web page. In such cases, this exception can be thrown.
  • StaleElementException: When an element is either deleted or no longer present in the DOM then, this exception can be thrown. We generally face this exception when the element we are interacting with is either destroyed or recreated again. 

46. Which API is used for database testing in the Selenium web driver?

JDBC (Java Database connectivity) is used for database testing in Selenium. This allows us to write the SQL (Structured Query Language) queries and execute them.

47. Can you write a small code snippet to launch a Chrome browser in Web Driver?

public class ChromeBrowserLaunchDemo { public static void main(String[] args) { //Creating a driver object referencing WebDriver interface WebDriver driver; //Setting the property to its executable's location System.setProperty("", "/lib/chromeDriver/chromedriver.exe"); //Instantiating driver object driver = newChromeDriver(); //Using get() method to open a webpage driver.get(""); //Closing the browser Driver.quit(); } } 

48. Can you mention the challenges you face when handling the Ajax calls in Selenium Web driver?

The following are the challenges we face while handling the AJAX calls,

  • Pause command in Ajax calls is not conventional and reliable in handling. Long pauses do cause the test case execution increases the time of execution. We can use the waitForCondition instead to test the AJAX applications.
  • Assessing the risk associated with these applications is difficult.
  • Encoding and Serialization in the AJAX applications make it difficult in developing the automation test case scenarios.

49. Can you explain how can you handle colours in web driver?

We can use the command getCssValue(arg0) to fetch the colors by sending the color as the argument.

50. Which implementation of the web driver is the fastest?

The web driver implementation HTML Unit Driver is the fastest of all. This is because this driver does not execute the tests in the browser but rather, executes only the plain HTTP which is quick faster as expected.

For a more detailed course, visit Great Learning Academy where you will find various courses on Machine Learning for free.

Also Read Top Common Interview Questions

Frequently Asked Questions on Selenium

What are the important topics in selenium?

  • Selenium Webdriver 3. x.
  • Difference between selenium versions like IDE, RC, WEB DRIVER
  • Selenium classes/interface/methods hierarchy from top to bottom
  • Selenium GRID implementation for local and remote nodes.
  • Java Concepts in detail.
  • TestNG Framework.
  • Advanced Reporting.
  • Page Object Model.
  • Page Factory Framework.
  • Data-Driven Framework.
  • Using reflection in the Page Object framework for creating pages dynamically.
  • Selenium usage with Docker.
  • Selenium JSON wire protocol details.
  • The Selenium integration with different tools like JMeter, cucumber, AutoIt, Jenkins.
  • Selenium frameworks like page factory, hybrid etc.

What can Selenium be used for?

Selenium is used for automation testing on various web browsers such as  Chrome, Mozilla, Firefox, Safari, and IE. With the help of a selenium web driver, one can easily automate browser testing.

What are selenium commands?

WebDriver command Usage
get() Launches a new browser and opensthe specified URLTakes a single string type parameter
getClass() This command is used to retrieve the Class object
getCurrentUrl() • This command is used to retrieve the URL of the webpage and doesn’t require any parameter.
getPageSource() • This command is used to retrieve the page source and doesn’t require any parameter and returns a string value
boolean result = driver.getPageSource().contains(“String to find”);
getTitle() • The command is used to retrieve the title of the webpage the user is currently working on.• The command doesn’t require any parameter and returns a trimmed string value
String title = driver.getTitle();
getText() • This command is used to retrieve the inner text of the specified web element

String Text = driver.findElement(“Text”)).getText();

getAttribute() • The command is used to retrieve the value of the specified attribute and requires a single string parameterdriver.findElement(“findID”)).getAttribute(“value”);
getWindowHandle() • This command is used in the situation when we have more than one window to deal with and the user can also switch back to the previous window if he/she desires.
private String winHandleBefore;winHandleBefore = driver.getWindowHandle();driver.switchTo().window(winHandleBefore);
getWindowHandles() • The command is similar to that of “getWindowHandle()” but here they deal with more than 2 windows only.

What are the basics of selenium?

Selenium was originally developed by Jason Huggins in 2004 as an internal tool as an open-source Web UI for automation testing. Selenium supports automation across different browsers such as  Internet Explorer, Mozilla Firefox, Google Chrome, and Safari, platforms such as Windows, Linux, Solaris, and Macintosh, and programming languages such as C#, Java, Perl, PHP, Python and Ruby and now it is also popular with Java and c#.

Read More: Basics of Selenium

What are the disadvantages of selenium?

  • Can’t rely on technical Support – As it is open-source software, it is hard to rely on technical support.
  • It supports Web-based applications only.
  • Selenium takes more time to create test cases as it has a programming interface only.
  • Difficult to set up Test Environment with tools like UFT, RFT, SilkTest etc.
  • Limited support for Image Testing.
  • New features may not work properly.
  • No Test Tool integration for Test Management.
  • No Built-in reporting facility.

Why is selenium so popular?

  • Transparency
  • Platform Independent
  • Quickens TTM and TTD
  • Fosters Continuous Integration Efforts
  • Visibility in End-to-End Testing
  • Reduces Turnaround Time
  • Integration With Other Tools

Is Selenium a framework?

Yes, selenium is a software testing framework for web applications that allows you to automate web app testing. With languages like Java, Python, Ruby, C#, you can write test scripts to run against browsers and VMs.

Which language is best for selenium?

Python and Ruby are the best binding languages for selenium as software may automatically load the driver if it is present in the same folder as your system or in the python path.

  • Java: Java remains the most popular programming language for test automation but not good as it is not a scripting language
  • JavaScript: JavaScript is used for test automation by 35% of our users writing their tests in this language.

The 10-week Data Science and Machine Learning: Making Data-Driven Decisions has a curriculum carefully crafted by MIT faculty to provide you with the skills, knowledge, and confidence you need to flourish in the industry. The program focuses on business-relevant technologies, such as Machine Learning, Deep Learning, NLP, Recommendation Systems, and more. The top-rated data science and machine learning program prepare you to be an important part of data science efforts at any organization.

36 Source: GreatLearning Blog

- Advertisment -

Most Popular

Recent Comments