When engineers create software, they need to test it. Testing is the most crucial part of the life cycle of software which is called a software development life cycle (SDLC).
Selenium is a popular automated testing tool. This open-source, automated testing tool is used to test web applications across different browsers.
Reasons behind the popularity of Selenium as a testing tool
The reasons for the popularity of Selenium as a testing tool are as follows:
- It may be used to test web applications against browsers like Chrome and Firefox, among others.
- It is independent of any platform. So, it may be deployed on a variety of operating systems like Macintosh and Windows.
As a result, any software company asks the applicants a few questions related to Selenium. The knowledge of Selenium is of utmost importance for the software developers and engineers.
Basic Level Selenium Interview questions and answers
A collection of questions that are asked about Selenium, along with their answers, is helpful for job applicants. The interview panel asks some questions to check the basic knowledge of Selenium. Interested candidates may check out the frequently asked questions and their answers given below:
1. What testing types does Selenium support? Explain them
Selenium supports two types of Testing. They are:
a) Regression testing: A few test cases are already executed. Sometimes, they need to be re-executed to check whether the existing functionalities are working fine. Regression testing refers to a full or partial selection of the test cases that have already been executed.
b) Functional Testing: It involves verifying all the functions of the application with the specification necessary.
2. How would you differentiate among Selenium 2.0 as well as Selenium 3.0?
Selenium 2.0 simplifies the development of automated tests for web applications. It represents the combination of the Selenium project with the Webdriver project.
Selenium 3.0 is an extended version of Selenium 2.0. It is more stable than its previous version. Some bug fixes are inbuilt.
3.What are the components of the Selenium suite? Explain them
The components of the Selenium suite are as follows:
Selenium Remote Control
a) Selenium Remote Control: This server permits the users to write application tests in various programming languages. This server accepts commands from the test script. Then, it sends the test scripts to the browser as Selenium core Java script commands.
b) Selenium Webdriver: This programming interface helps the creation and running of test cases. It ensures provisions to work on web elements are present. Since it has the facility to act natively with the web browsers, it doesn’t require a new server.
c) Selenium Grid: It was designed to distribute commands to a variety of machines simultaneously. So, it permits tests to be executed on many browsers and operating systems parallelly.
d) Selenium IDE: This plug-in to Firefox and Chrome was developed to fasten up the creation of automatic scripts. It is useful for recording the actions of the user on the web browser. Then, it exports the works as a reusable script.
4. Is Selenium testing limited in some way?
Selenium testing has its limitations like:
a) Basic knowledge of programming languages is necessary: Selenium Web Driver expects the users to have basic knowledge of programming language.
b) It only tests web applications: Selenium tests only web applications. It is not compatible with mobile or desktop apps. It has to be integrated with third-party tools like Appium to test mobile applications and desktop applications.
c) It gives limited support to image testing.
d) Absence of dependable technical support: Selenium is an open-sourced tool. So, it does not have dedicated technical support for resolving the queries of users.
5. What do you mean by the same-origin policy? How do you handle it?
We may explain the same-origin policy as a feature adopted for security reasons. As per this policy, a web browser lets scripts of webpage access the contents of another webpage. However, both the webpages need to have the same origin.
The same Origin policy also prevents a malicious Script of a webpage from accessing the sensitive data of another webpage.
6. What types of waits does Web driver support? Explain them
Web driver supports three types of wait:
a) Implicit Wait: It commands Selenium to wait for some time before displaying a “No such command” exception.
b) Explicit Wait: This command tells the Web driver to wait for some conditions before posting the “Element not Visible” exception.
c) Fluent wait: It shows the Web driver to wait for a state and the frequency with which we need to check status before displaying the “Element not visible” exception.
7. What do you mean by Selenese? How can you classify it?
A set of Selenium commands used to test a particular web application is known as Selenese. A tester tests whether Ajax is functional, whether some object exists on the UI, and broken links through Selenese.
Selenese is classified into three parts:
a) Activities: It comprises commands that interact directly with an application.
b) Accessors: It allows users to store some values to a user-defined variable.
c) Assertions: It verifies the present condition of a claim with the help of an expected state.
8. What do you mean by web locators?
A command that tells the Selenium IDE which GUI elements (like checkboxes and text boxes) need to work upon is known as a locator. In other words, a locator specifies the string of action.
9. How would you differentiate between driver.close and driver.quit?
Driver.close is a command that closes the current window of a browser. If many windows are simultaneously open, it will close the current window of focus.
Driver.quit is a command which closes all the windows of a browser that are open.
10. What is the use of X-path?
X-path is used to locate the WebElement in the web pages. It also helps in the identification of dynamic elements.
11. How would you differentiate between Verify commands and assert commands?
The Assert command allows us to check whether a particular element is on the page. If the asserted part is not found, the check automatically stops. As soon as the check is not found, the test Is terminated.
The Verify command will be executed even if a particular element is not available. Also, if any test fails, it is guaranteed that all the commands will run.
12. Why should testers opt for Selenium instead of QTP?
Selenium has certain advantages over QTP. They are as follows:
a) QTP is a commercial tool. On the other hand, Selenium is an open-source tool.
b) Selenium supports different web browsers like Firefox and Internet Explorer on operating systems like Windows and MAC. QTP is restricted to Internet Explorer on Windows.
c) Selenium is mainly used for testing web-based applications. QTP is used to test client-server applications.
d) Selenium supports multiple programming languages like Ruby and Python. QTP only supports the VB script.
13.Which four parameters do you need to pass in Selenium?
The four parameters that we need to pass in Selenium are as follows?
a) Port Number
14. What do you mean by the data-driven framework and keyword driven framework?
In a data-driven framework, the test data is kept separate. It is held outside the Test scripts and is read using external files, like Excel files.
In a keyword-driven framework, the data tables and keywords need to be developed independently of any test automation.
15. What are the differences between Selenium and Borland Silk?
The differences between Selenium and Borland Silk are as follows:
a) Selenium is a free test automation tool. Borland Silk is not a free testing tool.
b) Silk test uses script testing language. Selenium uses multiple programming languages like Java and Perl.
c) Selenium supports many browsers like Firefox, Internet Explorer, and Safari. Borland Silk only supports Firefox and Internet Explorer.
d) Selenium is used only for web applications. On the other hand, Borland Silk is used for client-server applications.
16.What do you mean by object repository?
An object repository permits a tester to store all the objects used in the scripts in a central location. It is integral to all the UI automatons. It doesn’t allow the purposes used for writings to be scattered indiscriminately throughout the test script.
17. What are “listeners” In Selenium Web driver?
Certain events are defined in the Selenium script. The function of “listeners” in Selenium Web Driver is to listen to those events and act accordingly. Two main types of listeners are as follows:
a)Web Driver listeners
b) TestNG listeners.
It allows the relevant departments to TestNG reports.
18. Why is session handling necessary while working with Selenium?
When a tester executes a test, the Selenium Web driver needs to interact with the browser. This way, it ensures the commands are executed.
Someone else may execute a different script in the same machine before the current execution is over. Session handle makes it easier to deal with such situations.
19. What is IntelliJ?
IntelliJ is an IDE. It helps people write a faster code for Selenium. The code written by IntelliJ is of good quality too.
20. What is meant by the desired Capability? How is it helpful in Selenium?
A series of value pairs are used to store the properties of a browser. The features include a browser name, the browser driver’s path followed in the system, and the version of the browser. This string of value pairs is known as the desired Capability. It stores these properties of the browser to consider the behavior at the time of the run.
Let us discuss how the desired Capability is helpful for Selenium:
a) Someone may want to run the test cases on different browsers having different versions and different operating systems. Desired Capability comes in handy then.
b) Desired Capability may be used for configuring the driver instance of Selenium Web driver.
21. What is meant by regular expressions? How can you proper widows be used in Selenium?
A regular expression is a unique string of texts used to describe a search pattern. A regular expression may be used in Selenium IDE through a keyword “regexp” as a prefix to the value. Models also need to be included to derive the expected benefits.
22. How do you explain the core extension?
Selenium Function Library provides some default functions. If someone wants to extend these default functions, he or she needs to create a core extension. A core extension is also known as a user extension. Readymade core extensions, which Selenium enthusiasts have created, can also be downloaded.
Intermediate level Selenium interview questions and answers
1. What do you mean by POM?
POM stands for Page Object Model. It is a design pattern that helps to create object repositories for web elements. The object repository allows many test cases to run on it. Pom improves the readability and reusability of the code.
2. Is It possible to automate Captcha?
No, Selenium does allow Captcha to be automated. The purpose of Captcha is to prevent automated programs and bots from accessing sensitive information. So, the whole purpose of Captcha is defeated, if Selenium allows it to be automated. An automation testing engineer needs to type the Captcha manually. All the other fields may be filled automatically.
3. How can Selenium handle pop-ups that are based on Windows?
Selenium is not a native supporter of the features of Windows. It was designed for handling web applications. Selenium should be combined with third-party tools like Robots to manage Windows-based functions.
4. Why will a Selenium IDE test fail?
A Selenium IDE test fails for the reasons mentioned below:
The element which Selenium IDE tried to access had not been created.
When a locator changed, and Selenium IDE cannot locate the element.
The element which Selenium IDE was trying to access did not appear on the webpage. In the meantime, the operation timed out.
5. Why is it better to choose Python over Java in Selenium?
a) Selenium accepts different programming languages like Java and Python. However, Java is preferable to Python. The reasons behind it are as follows:
b) Python programs run faster than Java programs.
c) Python may employ dynamic typing. On the other hand, Java uses static typing.
d) Python is more straightforward than Java.
6. What type of Java API is necessary to generate PDF reports?
Java API IText is needed to generate PDF reports.
7. Why is it challenging to handle Ajax calls in Selenium Web drivers?
People face multiple challenges while handling Ajax calls in Selenium Web drivers. They are as follows:
a) The developers have full liberty to make changes to the Ajax application. It makes the testing process complicated.
b) Many a time, the pause command is used to handle an Ajax call. The Pause command makes the Ajax call incredibly slow. So, the testing time takes a very long period.
c) It is difficult to gauge how risky specific Ajax applications may be.
Testing Tools like Ajax often use different techniques of coding for submitting POST data. So, it gets difficult for testing tools like Ajax to create automated test request data.
8. How is it advantageous to use GIT Hub for Selenium?
The advantages of using GIT HUB for Selenium are discussed below:
Many people working on the same project may update relevant product details and let the other team members know at the same time. It makes keeping a track of the progress easier.
9. How can a tester use multiple windows simultaneously, in Selenium?
The user may use a command named “select window” to toggle between windows. This command uses a title called “Windows” to identify which window he or she needs to switch
10. Could you mention anyone technical limitation while using Selenium RC?
Selenium is not authorized to access anything outside the browser. It is a technical challenge many people face while they use Selenium RC.
Do you have any Selenium Interview questions that are not answered here? Please visit Vinsys and fill up the inquiry form we will try to answer all.
We have an industry expert who illustrates certain pieces of code while explaining how to answer the questions. If you wish to embark on your journey as a test automation engineer, then here’s a certification course that will come in handy. Check out the Vinsys Selenium training course. This training is designed to train developers and manual testers to learn how to automate web applications with a robust framework, and integrate it within the DevOps processes of an organization, and help you master important concepts such as TestNG, Selenium IDE, and Selenium Grid.