Selenium Interview Questions

1. What is Automation Testing?

lella keerthi
7 min readSep 20, 2021

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. know more at Selenium online training

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.

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. know more at Selenium training

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.
  4. How many parameters do selenium commands have at a minimum?

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

  • Host

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.

  • Browser

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

  • URL

The application URL triggers the test cases within that.

9. What is the difference between the Absolute path and the 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]

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

Assert:

  • 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.

Verify:

  • 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.

11. 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. know more at Selenium online course

findElements():

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

12. 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.,

13. 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.

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

driver.close():

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.

driver.quit():

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.

15. 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.

16. 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. know more at Selenium online training from India

17. 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.

18. 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. know more at Best selenium online training
  • 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).

19. 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.

20. 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,

--

--