Blog
Selenium Interview Questions
- May 24, 2022
- Posted by: Laraonline2020
- Category: Interview Question and Answers

Selenium Interview Questions
1. What is Selenium?
Selenium Interview Questions : Selenium is an open-source (free) automated testing framework for validating web applications across multiple browsers and platforms. Selenium Test Scripts can be written in a variety of programming languages, including Java, C#, Python, and others. Selenium Testing is the term for testing done using the Selenium testing tool.
Selenium Software is a collection of tools, each of which caters to a specific organization’s Selenium QA testing requirements. The following is a list of tools incorporated within Selenium:
Selenium Integrated Development Environment (IDE)
- Selenium Remote Control (RC)
- Selenium WebDriver
- Selenium Grid
Jason Huggins was the one to invent Selenium in 2004. He was working as an engineer at Thought Works on a web application that required frequent testing. He designed a JavaScript program that would automatically control the browser’s behaviour after seeing that the repetitive Manual Testing of their application was getting increasingly inefficient. This application was given the name “JavaScriptTestRunner” by him. He released JavaScript Runner open-source, later renamed Selenium Core, after seeing promise in the notion to assist automate other online applications.

The Origin of Selenium Remote Control (Selenium RC):
Due to the limits imposed by the same-origin policy, Selenium Core testers had to install the entire application under test as well as the webserver on their own local PCs. So Paul Hammant, another ThoughtWorks engineer, decided to build a server that will function as an HTTP proxy, fooling the browser into thinking Selenium Core and the web application being tested are from the same domain. The Selenium Remote Control, or Selenium 1, was the name given to this system.
Selenium Grid’s Inception:
Patrick Lightbody created Selenium Grid to answer the need to reduce test execution times as much as feasible. He dubbed the system “Hosted QA” at first. It was capable of taking browser screenshots during key stages, which can later be analysed, as well as transmitting Selenium commands to several machines at the same time.
The Origin of Selenium IDE:
Selenium IDE is a Firefox extension built by Shinya Kasatani of Japan that can automate the browser using a record-and-playback function. He came up with this concept to speed up the process of building test cases even further. In 2006, he gave the Selenium IDE to the Selenium Project.
The Origin of WebDriver:
WebDriver was designed by Simon Stewart in 2006, at a time when browsers and web applications were getting more capable while also becoming more restrictive, thanks to JavaScript tools like Selenium Core. It was the first cross-platform testing framework to allow OS-level control of the browser.
In this article, we have covered the most frequently asked interview questions on Selenium using Java as the programming language. If you are appearing for a Selenium interview, you can expect questions from automated testing and Java as well.
2. What is meant by Selenium Suite and what are its different components?
Selenium is a package of several testing tools and is therefore often referred to as a Selenium Suite with each of these tools designed to cater to a different testing requirement.
Following are the different components of Selenium Suite:
- Selenium Integrated Development Environment (IDE): It is a Firefox/Chrome plug-in that is developed to speed up the creation of automation scripts by recording the user actions on the web browser and exporting them as a reusable script.
- Selenium Remote Control (RC): It is a server that enables users to generate test scripts in their preferred programming language. It accepts commands from the test scripts and sends them to the browser as Selenium core JavaScript commands, for the browser to behave accordingly.
- Selenium WebDriver: It is a programming interface that helps create and run test cases by directly communicating with the web browser and using its native compatibility to automate. Unlike RC, it doesn’t require an additional server to create and run test cases.
- Selenium Grid: It allows parallel execution of tests on different browsers and operating systems by distributing commands to different machines simultaneously.
3. What is automation testing, and what are its advantages?
Automation testing or Test Automation is a process of automating the manual testing process of an application or a system by using testing tools that allow you to create scripts that can be executed repeatedly, generating detailed test reports of the application or system under test.

Advantages of Automated Testing are:
- It supports both the performance and functional testing of an application or system.
- It facilitates the execution of repeated test cases.
- It allows the parallel execution of the test cases.
- It improves the accuracy and efficiency of the system by reducing the manual intervention of humans to generate test cases.
- It helps in testing a large scale test matrix.
- It saves valuable time and money for the testing team involved in the project.
4.What are the advantages of using Selenium as an automation tool?
Following are the advantages of using Selenium for automated testing :
- Open-Source: Selenium’s greatest strength, as previously said, is that it is a freeware and portable tool. There are no out-of-pocket expenses. The utility can be downloaded for free, and community-based help is also accessible.
- Language assistance: Java, Perl, Python, C#, Ruby, Groovy, JavaScript, and other languages are supported by Selenium. It has its own script, yet it is not constrained by it. It can work with a variety of languages, depending on the developers’ and testers’ preferences.
- Compatible with a variety of operating systems: Selenium may run on a variety of operating systems, including Windows, Mac OS X, Linux, and UNIX. A customized testing suite can be constructed on any platform and then executed on another using the Selenium suite of products. For example, you may write test cases in Windows and run them on a Linux system with ease.
- Browser compatibility: Selenium is compatible with a variety of web browsers, including Internet Explorer, Chrome, Firefox, Opera, and Safari. When running tests and testing them across multiple browsers at the same time, this becomes really useful.
- Programming languages and framework support: Selenium works with a variety of programming languages and frameworks. For source code compilation, it can, for example, integrate with ANT or Maven frameworks. It may also be used to test apps and generate reports using the TestNG framework. Continuous Integration (CI), can integrate with Jenkins or Hudson, and it can also integrate with other open-source tools to offer other functionalities.
- Tests on a variety of devices: On Android, iPhone, and Blackberry, Selenium Test Automation can be used to automate mobile web applications testing. This can aid in the generation of necessary results and the ongoing resolution of bugs present in the application.
- Regular updates: Selenium support is based on a community, which allows for frequent updates and upgrades. These upgrades are simple to install and don’t require any special training. Selenium is thus both resourceful and cost-effective.
- Selenium suites with a lot of content: Selenium is more than just a single tool or utility; it’s a full set of numerous testing tools that’s why it’s called a Suite. Each tool is tailored to specific testing needs and test environment constraints. Selenium also includes features such as Selenium IDE, Selenium Grid, and Selenium Remote Control (RC).
- Ease with which it can be implemented: Selenium has a user-friendly interface that makes it simple to develop and perform tests. Its open-source capabilities allow users to script their own extensions, making them simple to create, alter actions, and manipulate at a high level. Selenium’s reporting features are also one of the reasons for its popularity, as it allows testers to extract results and take action based on them.
5. What are the disadvantages of using Selenium as a testing tool?
The following are the disadvantages of using Selenium as a testing tool:
- Tests web applications only: Selenium supports the testing of only web-based applications. Mobile applications, Captcha, and Barcode readers cannot be tested using Selenium unless integrated with third-party tools like Appium and TestNG.
- No built-in reporting and test management facility: Selenium can generate reports only using third-party tools like TestNG or JUnit.
- Unavailability of reliable tech support: Since Selenium is an open-source tool, no dedicated support for user issues is available.
- May require the knowledge of programming languages: Some prior programming knowledge is required to use Selenium.
6. Why should Selenium be selected as a testing tool for web applications or systems?
Selenium provides the following advantages, which make it an excellent automated testing framework:
- It is free and open-source software with a large user base and supports providing community.
- It has cross-browser compatibility and supports multiple browsers like Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.
- It supports multiple operating systems such as Windows, Linux, macOS, etc.
- It facilitates the usage of multiple programming languages including Scala, Ruby, Python, PHP, Perl, Java, Groovy, C#, etc.
- It provides support for distributed testing as well.
7. Can selenium be used to launch web browsers?
Yes, Selenium provides good support to launch web browsers like Google Chrome, Mozilla Firefox, Internet Explorer, etc.
The following commands can be used to launch web browsers using Selenium:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
8. What is meant by Selenese? Explain different types of Selenium commands.
The language used for writing test scripts in Selenium IDE is called Selenese. It is a set of commands used to test your web application or system. Selenium commands could be divided into 3 major categories:
- Actions: These are the commands interacting directly with web applications.
- Accessors: These are the commands which allow users to store values to a user-defined variable.
- Assertions: They enable a comparison of the current state of the application with its expected state.

9. What is meant by a locator and name a few different types of locators present in Selenium.
A locator is an address for uniquely identifying web elements within a web page. There are different types of locators present in Selenium to identify web elements uniquely and accurately like:
- ID
- ClassName
- Name
- TagName
- LinkText
- PartialLinkText
- Xpath
- CSS Selector
- DOM.
10. State the major difference between “assert” and “verify” commands in Selenium.
Both “assert” and “verify” commands check whether the given condition is true or false and the only difference between them is that:
- Assert: Assert condition stops the execution of the testing if the given condition is false else would continue with the further tests.
- Verify: Verify the condition doesn’t stop the flow of execution irrespective of the condition being true or false.
11. What is meant by an exception test in Selenium?
An exception test is a test that expects an exception to be thrown inside a test class. It expects a @Test annotation followed by the expected exception name in the brackets.
Eg: @Test(expectedException = NoSuchElementException.class)
is an exception test for missing elements in Selenium.
12. What is meant by XPath in Selenium. Explain XPath Absolute and XPath Relative.
XPath, also defined as XML-Path (Extensible Markup Language Path), is a language used to query XML documents and provide functionalities like locating elements in Selenium by iterating through each element in a webpage. In XPath, data is stored in a key-value pair format similar to an HTML tag. It uses a single slash, i.e. ‘ / ’ for creating an absolute path, and a double slash, i.e. ‘ // ’ for creating a relative path for an element to be located on a webpage.
13.What is the difference between Selenium 2.0 and Selenium 3.0?
Selenium 2.0 is a tool that makes the development of automated tests for web applications easier. It represents the merger of the original Selenium project with the WebDriver project. Selenium RC got deprecated since the merge, however, was used for backward compatibility
Selenium 3.0 is the extended version of Selenium 2.0. It is inherently backward compatible and does not involve Selenium RC. The new version came along with several bug fixes and increased stability.
14,What is the same-origin policy and how is it handled?
Same Origin policy is a feature adopted for security purposes. According to this policy, a web browser allows scripts from one webpage to access the contents of another webpage provided both the pages have the same origin. The origin refers to a combination of the URL scheme, hostname, and port number.
The same Origin Policy prevents a malicious script on one page to access sensitive data on another webpage.
Consider a JavaScript program used by google.com. This test application can access all Google domain pages like google.com/login, google.com/mail, etc. However, it cannot access pages from other domains like yahoo.com
Selenium RC was introduced to address this. The server acts as a client configured HTTP proxy and “tricks” the browser into believing that Selenium Core and the web application being tested come from the same origin.
15.Mention the types of Web locators.
Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes, etc) it needs to operate on. Locators specify the area of action.
Locator by ID: It takes a string parameter which is a value of the ID attribute which returns the object to findElement() method.
driver.findElement(By.id(“user”));
Locator by the link: If your targeted element is a link text then you can use the by.linkText locator to locate that element.
driver.findElement(By.linkText(“Today’s deals”)).click();
Locator by Partial link: The target link can be located using a portion of text in a link text element.
driver.findElement(By.linkText(“Service”)).click();
Locator by Name: The first element with the name attribute value matching the location will be returned.
driver.findElement(By.name(“books”).click());
Locator by TagName: Locates all the elements with the matching tag name
driver.findElement(By.tagName(“button”).click());
Locator by classname: This finds elements based on the value of the CLASS attribute. If an element has many classes then this will match against each of them.
driver.findElement(By.className(“inputtext”));
Locator by XPath: It takes a parameter of String which is a XPATHEXPRESSION and it returns an object to findElement() method.
driver.findElement(By.xpath(“//span[contains(text(),’an account’)]”)).getText();
Locator by CSS Selector: Locates elements based on the driver’s underlying CSS selector engine.
driver.findElement(By.cssSelector(“input#email”)).sendKeys(“myemail@email.com”);
16.Explain what is the difference between Borland Silk and Selenium?
Silk Test Tool | Selenium Test Tool |
---|---|
Borland Silk test is not a free testing tool | Selenium is completely free test automation tool |
Silk test supports only Internet Explorer and Firefox | Selenium supports many browsers like Internet Explorer, Firefox, Safari, Opera and so on |
Silk test uses test scripting language | Selenium suite has the flexibility to use many languages like Java, Ruby,Perl and so on |
Silk test can be used for client server applications | Selenium can be used for only web application |
17. What is Object Repository ?
An object repository is an essential entity in any UI automations which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.
18. Explain how Selenium Grid works?
Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launch the browser and run the test. With entire test suite, it allows for running tests in parallel.
19. Can we use Selenium grid for performance testing?
Yes. But not as effectively as a dedicated Performance Testing tool like LoadRunner.
20. List the advantages of Webdriver over Selenium Server?
- If you are using Selenium-WebDriver, you don’t need the Selenium Server as it is using totally different technology
- Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility
- Selenium Web driver makes direct calls to browser using each browsers native support for automation, while Selenium RC requires selenium server to inject Javascript into the browser
21. Mention what are the capabilities of Selenium WebDriver or Selenium 2.0 ?
WebDriver should be used when requiring improvement support for
- Handling multiple frames, pop ups , multiple browser windows and alerts
- Page navigation and drag & drop
- Ajax based UI elements
- Multi browser testing including improved functionality for browser not well supported by Selenium 1.0
22. What is the difference between setSpeed() and sleep() methods?
This is one of the most asked selenium interview questions
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.
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(By.id(“your Textbox”)).sendKeys(“your keyword”);
25. How can you debug the tests in the Selenium IDE?
This is one of the most asked selenium interview questions
- 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?
This is one of the most asked selenium interview questions
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 in 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?
This is one of the most asked selenium interview questions
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. |
Hope you liked Laraonlinetraining Selenium Interview Questions