Selenium Interview Question and Answers

Selenium Interview Question and Answers

1) What are the WebDriver-supported Mobile Testing Drivers?

WebDriver supported "mobile testing drivers" are:



2) What are the popular programming languages supported by Selenium WebDriver to write Test Cases?

Selenium WebDriver supports the below languages to write Test Cases.



3) What's the difference between keyboard shortcuts and keyboard commands?

In most circumstances, TypeKeys() will produce a JavaScript event, whereas.type() would not.


4) What's the difference between the commands "type" and "type and wait"?

The "type" command is used to enter keyboard key values into a software web application's text box. It can also be used to choose values from a combo box, whereas the "type and wait" command is used when you finish typing and the software web page begins to reload. This command will wait for the page of the software program to reload before proceeding. You must use a basic "type" command if there is no page reload event when typing.


5) How do you distinguish between findElement() and find element()?

findElement(): Using the provided "locating technique," is used to locate the first element on the current page. It gives you a single WebElement as a result.

find elements() searches the current page for all elements using the supplied "locating mechanism." It gives you a list of web elements as a result.


6) What are you waiting for? In selenium, how many different sorts of delays are there?

For AJAX-based applications, Selenium Webdriver introduces the concept of waits. There are two kinds of waiting times:

Waiting Time Implicit Waiting Time Explicit Waiting Time Implicit Waiting Time Exp


7) What is the most significant drawback of implicit waiting?

The implicit wait has the main disadvantage of slowing down test performance.

Another drawback of implicit waiting is that:

Assume you've established a waiting time limit of ten Seconds. Because you ordered it to wait a maximum of 10 seconds, and the elements are shown in the DOM in 11 seconds, your tests will fail.


8) What is Selenium Grid, and how does it work?

Selenium Grid enables you to deploy your tests across numerous machines at the same time. As a result, the same text script may be used to run tests on both a Windows and a Mac machine. It cuts down on test execution time and gives immediate feedback.


9) What are the advantages of automating the testing process?

The following are some of the advantages of automation testing.

It enables the execution of many test scenarios.
It allows for parallel processing.
Unattended execution is encouraged by automation testing.
It improves precision. As a result, it reduces human-caused errors.
It helps you save both time and money.


10) What is the best way to acquire the text of a web element?

The get command is used to retrieve the inner text of a web element. The get command takes no parameters and returns a string type value. It's also one of the most commonly used commands for checking messages, labels, and errors, among other things, from web pages.


11) How to select a value in a dropdown?

We use the WebDriver's Select class to select the value in the dropdown.



  1. Select selectByValue = new Select(driver.findElement(By.id("SelectID_One")));  
  2. selectByValue.selectByValue("green value");  


  1. Select selectByVisibleText = new Select (driver.findElement(By.id("SelectID_Two")));  
  2. selectByVisibleText.selectByVisibleText("Lime");  
  1. Select select index = new Select(driver.findElement(By.id("SelectID_Three")));  
  2. selectByIndex.select index(2);  


12) What are the different types of navigation commands?

The navigation commands are as follows.


The above command needs no parameters and takes back the user to the previous webpage.



The above command allows the user to navigate to the next web page concerning the browser's history.



The navigate().refresh() command allows the user to refresh the current web page by reloading all the web elements.



The navigate().to() command allows the user to launch a new web browser window and navigate to the specified URL.




13) How to deal with frames in WebDriver?

An inline frame abbreviates as an iframe. It is used to insert another document within the current document. These documents can be HTML documents or simply web pages and nested web pages.

Select iframe by id

driver.switch().frame("ID of the frame");
Locating iframe using tagName

driver.switch().frame(driver.find elements(By.tagName("iframe").get(0));
Locating iframe using index


the the the the the the the the the frame (Name of Frame)

driver.switch().frame("name of the frame");
frame(WebElement element)

Select Parent Window



14) Is there an HtmlUnitDriver for .NET?

To use HtmlUnit first use the RemoteWebDriver and pass it in the desired capabilities

IWebDriver driver

= new RemoteWebDriver(DesiredCapabilities.HtmlUnit())

For the Firefox implementation to run, use

IWebDriver driver

= new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript())


15) How can you redirect browsing from a browser through some proxy?

Selenium facilitates a PROXY class to redirect browsing from a proxy. Look at the example below.


String PROXY = "";

org.open a.selenium.Proxy proxy = new.org.openqa.selenium.Proxy();

proxy.set HTTP proxy(Proxy)



DesiredCapabilities cap = new DesiredCapabilities();

cap.setCapability(CapabilityType.PROXY, proxy);

WebDriver driver = new FirefoxDriver(cap);


16) What is POM (Page Object Model) and how does it work? What are the benefits?

The Page Object Model is a design approach for storing web UI elements in an object directory. Each web page must have its page class. The page class is in charge of locating WebElements in web pages and performing operations on them.

The following are some of the advantages of adopting POM.
It enhances code readability by separating actions and flows in the UI from Verification.
Because the Object Repository is independent of Test Cases, it can be used for several tests.
Coding reusability


17) How to capture screenshots in WebDriver?

Below is the program to capture screenshots in WebDriver.

import org. JUnit.After;
import org. JUnit.Before;
import org. JUnit.Test;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.open a.selenium.OutputType;
import org.open a.selenium.TakesScreenshot;
import org.open a.selenium.WebDriver;
import org.open a.selenium.firefox.FirefoxDriver;

public class TakeScreenshot {
WebDriver driver;
public void setUp() throws Exception {
driver = new FirefoxDriver();
public void tearDown() throws Exception {

public void test() throws IOException {
//capture the screenshot
File scrFile = ((TakeScreenshot)drv).getScreenshotAs(OutputType.FILE);
// paste the screenshot to the desired location
FileUtils.copyFile(scrFile, new File("C:\\Screenshot\\Scr.jpg"))


18) How to type text in a textbox using Selenium?

The sendKeys("String to be entered") is used to enter the string in a textbox.


WebElement username = drv.findElement(By.id("Email"));
// entering username


19) How can you find if an element is displayed on the screen?

WebDriver allows users to check the visibility of the web elements. These web elements can be buttons, radio buttons, drop, checkboxes, boxes, labels, etc. which are used with the following methods.

is displayed()

is displayed():
boolean buttonPresence = driver.findElement(By.id("gbqfba")).isDisplayed();
boolean buttonSelected = driver.findElement(By.id("gbqfba")).isSelected();
boolean searchIconEnabled = driver.findElement(By.id("gbqfb")).isEnabled();


20) How to click on a hyperlink using link text?

The above command searches the element using a link text, then click on that element, and thus the user will be redirected to the corresponding page.

The following command can access the link mentioned earlier.


Follow Us on!

How can we help you?

To request a quote or want to meet up for a course discussion, contact us directly or fill out the form and we will get back to you promptly.