Register Login

Selenium Interview Questions

Selenium Interview FAQ's

What is selenium?

Selenium is a portable software-testing framework for web applications. It provides a playback tool for authoring tests without the need to learn a test scripting language. Selenium is an extremely popular portable framework used to test web applications. It provides the features needed by a user to author automated tests without the need of a test-scripting language. It supports testing of the functional aspects of an application across several platforms and browsers. It is not a single utility or tool, but a package of various testing tools due to which it is called a Suite. Each of these testing tools perform different testing functions.

What are components of selenium?

There are four components of Selenium:

  1. Selenium Remote Control
  2. Selenium IDE
  3. Selenium Grid
  4. Selenium WebDriver

What is selenium ide?

Selenium IDE provides an integrated development environment (IDE) for the tests. It allows the editing, recording and debugging of tests and was initially known as the Selenium Recorder. With the autocomplete support and its ability to make commands move quickly, it provides the ideal environment for the creation of Selenium tests.

Few features of Selenium IDE are:

  1. Intelligent selection of field using IDs, names, etc.
  2. Easy recording and playback
  3. Autocompletion of the common Selenium commands
  4. Debugs and sets breakpoints
  5. Walk-through tests, etc.

What is selenium webdriver?

Selenium WebDriver is a browser automation framework responsible for sending commands to the browser once it receives them. It is achieved by a browser-specific driver which retrieves the results after sending the commands to the browsers. Most drivers launch and then access the browser application (like Chrome, Firefox, Internet Explorer, etc.), thus Selenium is different from the rest in terms of features and functionality. It supports languages like C#, Java, PHP, Ruby, Python and Perl.

What is selenium testing?

SAF refers to a customized framework that has been developed using Selenium. It serves as a widely accepted web application and automation tool for developers. It is responsible for shrinking test cycle times as well as the related costs. This software testing framework is portable in nature and very helpful for testing for web applications. In Selenium tests, the test codes can be written in the form of HTML tables or as codes in different popular programming languages. Selenium IDE is a Selenium test that is in the form of a Firefox add-on; this IDE can be used for the creation of relatively simpler test suites and test cases. Additionally, Selenium 1 or Selenium Remote Control serves as the first Selenium tool that allows developers to work with programming languages involved in creating complex tests.

What is framework in selenium?

A framework is a structure that helps to maintain the code in an easier manner. Without this framework, the code and the data would be placed in the same place. This in turn would make them neither readable nor re-usable. Frameworks help to increase code re-usage and readability, increase portability and reduce the maintenance cost of scripts.

What are types of frameworks in selenium?

There are three types of frameworks which have been created by the Selenium WebDriver in order to automate the manual test cases:

  1. Data-driven Test Framework
  2. Hybrid Test Framework
  3. Keyword-driven Test Framework

How to handle multiple windows in selenium?

During the instantiation of a WebDriver object, every window is assigned with an alphanumeric id, which is known as the ‘window handle’. The control between windows are switched using these ids and necessary actions are then performed. The ‘SwitchTo’ methods use the window handle values to switch control between different windows.

How to take screenshot in selenium?

Screenshots are useful for bug analysis. In Selenium, developers can go for automatic screenshots, even during the time of execution. A WebDriver instance has to be type casted to TakesScreenshot for enabling the process. The steps for taking screenshots in Selenium are:

  • The web driver object is converted to TakeScreenshot
TakesScreenshot scrShot =((TakesScreenshot)webdriver);
  • The image file is created by calling the getScreenshotAs method
File SrcFile=scrShot.getScreenshotAs(OutputType.FILE);
  • The file can be copied to the desired location.

How to scroll down in selenium?

The JavaScriptExecutor interface is used for scrolling down in selenium. This interface helps to execute the methods through the WebDriver.

What is XPath in selenium?

Xpath finds an element when it cannot be found by general locators – id, name, class etc. Xpath consists of the path of an element which is situation on the web page. Here are the two types of xpath:

  1. Relative Xpath – the path begins from the mid of the DOM structure. The paths are comparatively shorter and start with a double forward-slash (//).
  2. Absolute Xpath – In this direct way of finding the element, the disadvantage lies in the fact that changes made to the element path would lead in a failure of the XPath too. They start with a single forward-slash(/).

How to write XPath in selenium?

Xpath can be written in many ways but the basic syntax is as follows:

//tagname[@attrubute=’value’]

The different methods of writing dynamic Xpath in case of selenium comprise of using:

  • Single Slash
  • Double Slash
  • Single Attribute
  • Multiple Attribute
  • AND
  • OR
  • contains()
  • starts_with()
  • text()
  • last()
  • position()
  • index()
  • following xpath axes
  • preceding xpath axes

What is testing in selenium?

TestNG (in which NG stands for Next Generation) is a testing framework inspired by Junit. It helps generate a detailed report with the details of the tests that have been passed, skipped or failed. It eliminates few limitations showcased by the older frameworks. TestNG  provides users with the ability to develop powerful and flexible tests using the features of grouping, easy annotations, parametrizing and sequencing.

How to read data from excel in selenium? The codes and screenshots can be placed in-house.

As Selenium supports the automation of web browsers only, developers have to take the help of third party APIs of the likes of JExcel, Apache POI, etc. to write and read data from excel files. Apache POI refers to an AP that is scripted in Java. It is a freeware that offers flexible options to read/write files. Packaged with predefined methods, numerous classes, and different interfaces, it is the go to solution for reading data from Excel in Selenium.

 How to handle popup in selenium?

In automation, there are instances when multiple windows and popups have to be handled in web applications. The required activity necessitates the switching of controls among several popups and window from one to another with a view of completing different operations. After the popups are handled, the users have to return to the parent or main window. Selenium web driver provides different methods of handling popups and multiple windows.

Driver.getWindowHandles();

In order to handle the open popups / windows by a web driver,  developers may want to utilize the "Driver.getWindowHandles()" provided by the web driver. This handle can be used for switching from one window to the other in any web application. The return type of this action is Iterator<String>.

Driver.getWindowHandle();

The main window/ popup is to be handled by driver.getWindowHandle() when any site opens and loads. It handles the current window that’s uniquely identified within the driver instance. The return type of this handle is String.

How to maximize window in selenium?

The ‘maximize()’ method belongs to the ‘Window’ interface of the ‘driver class’, it is called to maximize a window in Selenium.

What is webelement in selenium?

WebElement refers to an element present in the DOM. Selenium represents a DOM element in terms of a WebElement so that it can be manipulated as per user requirements. A WebElement reference to any given element within the DOM. Selenium represents DOM elements through web elements in order to help developers manipulate the same fitfully.  The Selenium Web Driver offers two methods for finding these elements.

findElement() – this method finds a singular web element and returns the same as a WebElement object.

findElements() – this method returns a list of different WebElement objects that match with the locator criteria.

What is maven in selenium?

Maven helps manage the entire lifecycle of the test project. It defines project structure, build, dependencies and test-management. By using pom.xml (Maven) one can configure the dependencies required for developing testing as well as the running codes. It is basically a ‘build-management tool’ used to define how a .java file gets compiled to a .class file and can be packaged into a .jar file. It aims to be fully self-contained such that one does not require additional scripts or tools for incorporating various tasks like installing necessary libraries etc.  It is quite portable due to which one doesn’t face issues with the working of the same build script on different computers.

What is selenium grid?

Selenium Grid specializes with the running of tests across various browsers, operating systems and machines simultaneously. It basically supports distributed and parallel execution of tests. It reduces the amount of time required for the suite to finish a test pass.

How to handle dropdown in selenium?

Handling dropdowns are like handling any other elements on a page. A drop-down can be chosen using Id, Name, Xpath etc. However, dropdowns require the ‘Select’ package to be imported to help users perform an action on them. Once the package is installed a new ‘Select’ Object is created which belongs to the class ‘Select’. This is then used to select or deselect an option in the dropdown. The dropdown WebElement is passed as a parameter to the constructor for the initialization of the ‘Select’ object.

The three ways in which an option can be selected are:

  1. selectByValue – selects an option due to its ‘value’ attribute
  2. selectByIndex – selects an object due to its index, which starts from 0
  3. selectByVisibleText – selects an option due to the text placed over the option.

How to select radio button in selenium?

The radio button can be chosen by using the ID, Element value or the CssSelector and selected by using the ‘click()’ method.

What is data driven framework in selenium?

At times when the need to run a test on various data sets arises, the creation of a new test every time can be cumbersome and time-consuming. Data-driven framework helps us overcome the same. The test data is first created in the form of a spreadsheet and then imported to the testing tools due to which the test data and tests are kept separate. This allows for the same test to be run multiple times on different validation and input values.

How to find xpath in chrome for selenium?

There is no need of an extension in chrome now. To find the xpath in chrome, right-click on the element followed by ‘Inspect Element’, once inside the inspector, right-click on the element then go to ‘Copy’ click on ‘Copy Xpath’.

What is an element in Selenium?

Objects or controls in a webpage are called elements. Different ways of finding elements in webpage include element ID, Name, Tags, etc.

What is automation testing?

A: As opposed to manual testing, automation testing is the process where the testing is done automatically with a set of tools without manual interference.

What are the types of tests supported by Selenium?

A: Selenium supports two types of testing:

1.Functional Testing
2.Regression Testing

What is meant by Assertion in Selenium?

Assertion in Seleniun is a verification point to verify whether the applications conform to expectations.

What is meant by Selenese?

A: Selenese is the programming language to write test scripts for Selenium IDE.

What are locators?

Locators are addresses to uniquely identify a web element within a webpage. The locators used in Selenium include:

  • ID
  • Name
  • ClassName
  • TagName
  • CSS Selector
  • LinkText
  • PartialLinkText
  • DOM
  • Xpath

What is XML?

A: XML or Extensible Markup Language stores transports and organizes arbitrary data. Data is stored in key value pairs similar to HTML tags, and since both are markup languages, XPath can be used to locate HTML elements of a webpage.

How are single slash (/) and double slash (//) different in XPAth?

A: The difference in XPath is as follows:

Single Slash (/): Creates an absolute XPath to start the selection from document or start node.
Double Slash (//): Creates a relative XPath to start the selection from anywhere within the document.

Why is Selenium Grid used?

A: Selenium Grid is used to execute the testing scripts on many browsers and platforms simultaneously. This allows the testing to be distributed, testing under different environments, and significantly reduced testing time.

Can HTML ID and Name be used while using Selenium IDE?

A: Yes, HTML name and ID is available and can be used in Selenium.

Which Mobile Testing Drivers are supported by Selenium WebDriver?

A: Mobile Testing Drivers supported by WebDriver include AndroidDriver, iPhoneDriver, and OperaMobileDriver.

What are Assert and Verify commands, and how are they different?

A: Both Assert and Verify commands check to see whether a give condition is true or false. The difference lies in how the test proceeds with the result. When Assert command is used, the program shall execute the successive testing phases only if the condition is true, and will completely stop test execution if the result is false.
On the other hand, the Verify command will not stop test execution, that is, the test will be completed even if the condition is returned false.

How are TypeKeyes and Type commands different?

A: The TypeKeyes command triggers a JavaScript event and fills the value attributes using JavaScript, while the Type command does not start JavaScript, but simply emulates typing of an actual user.

What types of wait are available in Selenium WebDriver?

A: There are two types of wait in Selenium WebDriver:

1.Implicit Wait: Provides a specific user defined time span during which the test execution is stopped before an element is found in each test conducted throughout the entire program.

2.Explicit wait: Causes execution to be stopped till a custom defined condition is met for a specific instance only.

How are driver.close() and driver.quit() commands different?

A: Neither the .close() command nor .quit() command need parameters or return values. The difference is while the .close() command closes the particular browser window being accessed by WebDriver, the .quit() command shuts down all the windows opened by the program

What parameters need to pass in Selenium?

A: Four parameters need to pass in Selenium: Host, Port Number, Browser, and URL.

What is JUnit and JUnit Annotations?

A: JUnit is a Java based open source unit testing framework introduced by Apache. Annotations are some special types of syntax based meta data that are added to a JAVA Source Code.

How are find element() and find elements() different?

A: The find element() command locates the first element in the working page and returns one WebElement, while the find elements() command locates all the elements asked for in the present page and returns the list of these WebWlements.

What is Module Based Testing Framework?

A: The Module Based Framework separates the complete application being tested into separate individual units or modules, and separate scripts are written for each of these modules. When combined, these separate scripts make up the complete testing program.

What is Library Architecture Testing Framework?

A: The common steps of the test are determined and grouped in a library under functions which are called wherever required in the test script.


×