Selenium Interview Questions and Answers

Selenium Interview Questions and Answers

Selenium Interview Questions and Answers

Facing an interview is always a tough task, specially for a vast subject like Selenium. So, we decided to work and create a guide on Selenium interview questions and answers. The complete guide is under development and will be development by the end of this year.

In this post, we are publishing some of the interview questions (coding based), usually asked in the interview.  Suggested answers are also provided. It’s always a good idea to help customers.

How to simulate scrolling down a page in Selenium?

JavaScript  can be used to scroll up and down in selenium web driver. Below code is used to scroll down vertically 250 pixels –

JavascriptExecutor js = (JavascriptExecutor)driver;


OR we can use below code to scroll for an element –

JavascriptExecutor js = (JavascriptExecutor)driver;

js.executeScript(“arguments[0].scrollIntoView(true);”, date);

What are the different types of waits available in Selenium?

There are two types of wait in Selenium webdriver:

  1. Implicit Wait
  2. Explicit Wait

Implicit Wait: In Implicit wait, if WebDriver is not able to find an element in the Document Object Model (DOM), it will wait for a defined amount of time for the element to appear in the DOM. The Implicit wait may slow down your tests, because once set, the implicit wait is set for the lifetime of the WebDriver object’s instance.

Implicit waits are implemented as shown below:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Explicit Wait: Explicit wait is a type of wait (applied through code piece), which is used to stop the execution till a specific condition is true.We use WebDriverWait and ExpectedCondition classes of Selenium web driver to implement explicit wait.

Unlike Implicit waits, explicit waits are applied for a particular instance only.

Explicit waits are implemented as shown below:

WebElement txtFirstname = driver.findElement(By.cssSelector(“input[name=’firstname’]”));

WebDriverWait wait = new WebDriverWait(driver,10);


How to perform double click using WebDriver?

Actions class of web driver can be used to perform action of double click on an element. The code to simulate double click using Webdriver is shown below: 

WebElement button = driver.findElement(By.cssSelector(“input[name=’button1′]”));

Actions builder = new Actions(driver);


Is FirefoxDriver a Class or an Interface?

FireFoxDriver is a class that implements WebDriver interface.

WebDriver is an Interface, and we define a reference variable (driver) whose type is an interface, as shown below.

WebDriver driver = new FireFoxDriver;

Now any object we assign to it must be an instance of a class that implements the interface.

We can create a reference variable of an interface, but we can’t instantiate any interface or in other words create object of an interface.

WebDriver driver = New WebDriver;

Above code will throw an error as shown below:

Webdriver Interface error

How do you select a value in the drop down?

Value in the drop down can be selected using WebDriver’s Select class.
For example consider HTML file like this –



<select id = “designation”>

<option value = “PM”>Program Manager</option>

<option value = “QA”>Quality Analyst</option>

<option value = “prog”> Programmer </option>

<option value = “SM”> Sales Manager </option>





Let’s look at the code to select a value “Quality Analyst” from the drop down:

Select s1 = new Select(driver.findElement(“designation”)));

 //selecting By Index number


//Select By Visible Text

s1.selectByVisibleText(“Quality Analyst”);

// Selecting By Value:


How to capture a screenshot in Selenium Web driver?

The code to capture screen shot in Selenium is shown below:

publicvoid takeSnapshot()




TakesScreenshot ts = (TakesScreenshot) driver;

File image;

image = ts.getScreenshotAs(OutputType.FILE);

File destFile = new File(“D:\\OnlineTraining\\OnlineBatch\\Screenshot.jpg”));

FileUtils.copyFile(image, destFile);


catch (IOException e)


System.out.println(“Input Output Exception “);


}  }

In this way, we can create a method for capturing screenshot and call it whenever we need to take a screenshot in multiple scenario.

Selenium Tutorial for Beginners

About Techcanvass

Techcanvass offers IT certification courses for professionals. We are an IIBA endorsed education provider (EEP), iSQI ATP (for Certified Agile Business Analyst Training) as well as Agile Testing alliance partner for CP-SAT certification training in Selenium.

Our Selenium 3.0 Training programs along with DevOps courses are designed for Manual testing professionals with basics of Java and Python covered.

Selenium Training with Job readiness package