Software testing as one of the crucial phases of the software development lifecycle ensures the release of bug-free software in the market which would be able to meet the needs of the customers.
Testing can be undertaken in a manual as well as in an automated fashion. While there are a number of Test Automation Tools available, Selenium has emerged as one of the foremost Testing Tools of choice. Consequently, Selenium related jobs have emerged as coveted spots within the tech industry & by emphasizing upon some of the most significant Selenium Interview Questions, this guide will help you ace a Selenium Interview like a pro.
This blog has been carefully curated as a helpful guide covering some of the most important Selenium Interview Questions which appear in interviews across companies. This list of Selenium Interview Question and Answers focus on some of the most important areas that you must pay attention to as you prepare for your interview.
➡ For the purpose of convenience, this blog has been divided into four parts and covers the top 30 Selenium Interview Questions and Answers.
Interview Questions on Selenium: BASIC Level
1. What are the different Selenium Suite Components?
The Selenium Automation software is not a single tool, but a suite of software, each of which serves a specific set of testing purposes for the organization. The tools are:
- Selenium Integrated Development Environment (Selenium IDE): It works as a Firefox plug-in which can be used to record and execute test cases. It was primarily created to accelerate the production of automation scripts
- Selenium Remote Control (Selenium RC): It was the first flagship testing tool which allowed users to write test cases in the preferred language of the user. It provides for cross-browser testing as well as data-driven testing.
- Selenium WebDriver: It was created by Simon Stewart in 2006, as a solution to the shortcomings of Selenium RC. It provides an interface for creation as well as execution of test cases and it is possible to identify web page elements through the test cases and take appropriate action.
- Selenium Grid: It makes use of the Hub-Node design which helps in simultaneous execution of more than one test case on different machines which happen to be remotely located. There is one master system which is the hub and it controls the other child systems which are the nodes. Thus, it provides for parallel execution.
2. Why should you use Selenium? What are its advantages?
- Open-source and free
- Supports test scripts in different programming languages
- Provides for execution of test cases on multiple browsers and more than one operating systems
- Facilitates parallel testing and has a huge community support
- Provides for integration with JUnit and TestNG
- Allows for Continuous Testing through integration of Selenium with Maven, Jenkins and Docker
3. What is the difference between Selenium 2.0 and Selenium 3.0?
Selenium 2.0 provided for the merger of the Selenium Webdriver project with the original Selenium Project. Ever since then, Selenium RC got disapproved of, but was still used for backward compatibility.
Selenium 3.0 is held to be the extended version of Selenium 2.0. It is backward compatible, does not include Selenium RC and is inherently stable with several bug fixes.
4. What is Selenese? What are its types?
Selenese refers to Selenium commands which act as instructions for executing the test cases. A test script can be seen as a sequential collection of these Selenese commands.
There are three types of Selenese:
- Actions: These commands are used for conducting operations on and interacting directly with the target elements.
- Accessors: This command helps in storing values in a variable.
- Assertions: These commands act as checkpoints for keeping track of the sequential execution of commands.
5. What is the Same-Origin Policy? How was it resolved?
The problem posed by the same-origin policy was sought to be rectified through the introduction of Selenium RC. It did seek to resolve the issue by including a HTTP proxy server which could deceive the browser into believing that the web application and the test script came from the same source. Thus, the issue of the same-origin policy is handled through the proxy injection method.
6. What are the different test types supported by Selenium?
The different test types supported by Selenium are:
Functional Testing: This kind of testing is conducted in order to determine whether an application functions as per the requirements of the project. Generally, it involves black box testing and does not concern itself with the source of the code.
- Regression Testing: It involves selection (full or partial) of already executed test cases in order to get them re-executed for evaluating the performance of existing functionalities.
7. What is the difference between Verify and Assert Commands?
- Verify: This command is used to check whether an element is on a page. It is used to specify whether a condition is true or false. If the element is not there, the test will keep on executing. Even if any of test fails, the rest of the commands will continue to run.
- Assert: This command is used to check whether an element is on the page or not. If the asserted element is not present, then the test will stop and will not continue further. Thus, the test terminates at the point where the check fails.
8. What is the difference between single slash and double slash in XPath in Selenium?
- Single Slash (/)
- It helps in starting the selection from the document or the start node
- It allows the user to create Absolute expressions in XPath Selenium
- Double Slash (//)
- It helps in starting the selection from anywhere in the document
- It allows the user to create Relative expressions in XPath Selenium
9. What is a locator? How will you locate an element in Selenium?
Locators in Selenium act as means for finding and matching elements on a webpage with which the user needs to interact with. Depending on the type of element which needs to be located, there are different types of locators present.
- Partial Link
- Link Text
- CSS Selector
10. What are the technical limitations of Selenium?
- It can only be used to test web applications and is not suitable for testing mobile or desktop software applications
- It cannot acquire access to web elements detected to be outside the web application which is under test
- There is no assured user support, apart from customer communities
- It cannot be used for image testing or data-driven testing independently
- It requires prior knowledge of programming language to write tests
- Selenium cannot be used to test Captcha and barcode readers
11. What is the Page Object Model (POM)? What are its advantages?
POM can be understood as a design pattern which helps in creating object repositories for the web UI elements. The web pages of applications have corresponding page classes which help in locating web elements and undertaking actions on them.
- The same object repository can be used in multiple tests, as the repository itself is independent of test cases
- It helps in providing for code readability, as it supports separate flows and operations on the UI from verification
- It also enhances the reusability of the code