preloader
Selenium Interview Questions

Top Selenium Interview Questions and Answers for 2022 Interviews

author image

If you are appearing in a web developer interview then you need to prepare these Selenium Interview Questions. Here we have given you 50 Selenium Interview questions and answers which relate to automation testing of a Web UI. Here is a list of the most frequently asked Selenium interview questions from freshers and experienced, so prepare them for your upcoming job interview. It is a wide language used with all other languages so you need to prepare this topic on a general basis to be prepared for any question asked related to automation testing.

About Selenium: It is an open-source web User Interface (UI) that has a range of tools and libraries which support web browser automation. It was developed by Jason Huggins in 2004 as an internal tool. Selenium helps automation through various browsers, platforms, and programming languages.

Also, prepare for Core Java interview questions, Networking interview questions, and other language interview questions from here.

Selenium Interview Questions

1. Explain test automation or automation testing?

2. Tell some benefits of automation testing?

3. Tell some frequently used Functional Automation Testing tools

4. Tell some frequently used Non-Functional Automation Testing tools

5. Explain Selenium?

6. Name different components of Selenium?

7. Tell the programming languages, browsers, and operating systems that Selenium supports?

8. Tell the various changes/upgrades in different Selenium versions?

9. Name different test types supported by Selenium.

10. Explain Selenium IDE?

11. Explain Selenese?

12. Name different ways of finding a web element in Selenium?

13. Name the types of WebDriver API in Selenium?

14. Tell some Automation tools that will be integrated with Selenium to attain continuous testing.

15. Explain assertion in Selenium?

16. Explain assert and verify commands?

17. Explain XPath?

18. What do you understand with XPath Absolute and XPath attributes?

19. Differentiate between "/" and "//" in XPath?

20. Tell the types of annotations used in Selenium?

21. Name the WebDriver that supports Mobile Testing Drivers?

22. Name some Selenium WebDriver supporting programming languages to write Test Cases?

23. Differentiate between type keys and type commands?

24. Differentiate between "typeAndWait" and "type" commands?

25. Differentiate between findElement() and findElements()?

26. Explain wait and its types?

27. Tell the main disadvantage of implicit wait?

28. Explain Selenium Grid?

29. Tell the way to launch various browsers in Selenium WebDriver?

30. Make a code snippet to execute right-click an element in WebDriver.

31. Mention a programming code snippet to execute mouse hover in WebDriver.

32. Tell the various methods to refresh a web page in WebDriver?

33. Create a code for navigate back and forward in browser history?

34. Tell the syntax to invoke an application in WebDriver?

35. Tell the way to get a text of a web element?

36. Tell the way to select a value in a dropdown?

37. Tell different types of navigation commands?

38. In WebDriver, How to deal with a frame?

39. Is there an HtmlUnitDriver for .NET?

40. Show an example of redirect browsing from a browser through some proxy?

41. Explain POM (Page Object Model) and its advantages?

42. Tell the instructions to capture screenshot in WebDriver?

43. How to enter the string in a textbox using Selenium?

44. Tell the method to find if an element is shown on the screen?

45. Tell the way to click a hyperlink using link text?


Learn More Interview Questions Here:


Selenium Interview Questions and Answers

1. Explain test automation or automation testing?

Automation testing uses automation tools to type and perform test cases, no physical involvement is required for running an automated test suite. Testers favor automation tools to type test scripts and test cases and then combine them into test suites.

Automation testing allows the use of special tools to automate the execution of manually designed test cases without any intervention of man. Automation testing tools can use the test data, manage the execution of tests, and relates the actual result with the expected result.

2. Tell some benefits of automation testing?

  • Automation testing helps functional testing as well as performance testing of an application.
  • It also helps in the execution of repeated test cases.
  • It allows parallel execution.
  • It helps in testing a big test matrix.
  • It increases accuracy as there are no human errors.
  • It saves a lot of time and money.

3. Tell some frequently used Functional Automation Testing tools

  • Teleric Test Studio, Developed by Teleric.
  • HPE Unified Functional Testing (HP - UFT formerly QTP)
  • TestingWhiz
  • Tosca Testsuite
  • Quick Test Professional, provided by HP.
  • Watir
  • Rational Robot, provided by IBM.
  • Selenium, open-source.
  • Coded UI, provided by Microsoft.
  • Auto It, Open Source.

4. Tell some frequently used Non-Functional Automation Testing tools

  • Load Runner, provided by Hp.
  • Burp Suite, provided by PortSwigger.
  • JMeter, provided by Apache.
  • Acunetix, provided by Acunetix.

5. Explain Selenium?

Selenium is a handy framework used for software testing. Selenium tool works as a playback tool for running functional tests without the knowledge or learning of a test scripting language.

It is the most widely used open-source Web User Interface (UI) automation testing tool. Selenium is developed by Jason Huggins in 2004 as an internal tool. Selenium helps automation through various browsers, platforms, and programming languages.

6. Name different components of Selenium?

It is not just one tool but a combination or suite of different software, each having a unique approach to help automation testing. It includes four major components:

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (Now Deprecated)
  • WebDriver
  • Selenium Grid

7. Tell the programming languages, browsers, and operating systems that Selenium supports?

  • Programming Languages: C#, Java, PHP, Python, Ruby, JavaScript, Perl.
  • Operating Systems: Android, Windows, iOS, Linux, Solaris, Mac.
  • Browsers: Google Chrome, Mozilla Firefox, Opera, Edge, Safari, etc.

8. Tell the various changes/upgrades in different Selenium versions?

Selenium v1.0:

  • Version 1.0 was the first release of Selenium.
  • It consists of three tools: Selenium IDE, Selenium RC, and Selenium Grid.

Selenium v2.0:

  • In version “2.0”. Selenium WebDriver was introduced substituting Selenium RC
  • With the onset of WebDriver, RC got denounced and moved to the legacy package.

Selenium v3:

  • The latest Selenium 3 has new upgraded features and functionalities.
  • It consists of Selenium IDE, Selenium WebDriver, and Selenium Grid.

9. Name different test types supported by Selenium.

  • Functional Testing
  • Sanity Testing
  • Regression Testing
  • Responsive Testing
  • Smoke Testing
  • UI testing (black box)
  • Cross Browser Testing
  • Integration Testing

10. Explain Selenium IDE?

Selenium IDE is applied as a Firefox extension that gives record and playback functionality on test scripts. It permits testers to transfer recorded scripts in different programming languages like HTML, Ruby, Java, Python, RSpec, C#, TestNG, and JUnit.

Selenium IDE is limited and the created test scripts are not robust, and portable.

11. Explain Selenese?

Selenium is also called “Selenese” is the set of instructions used in Selenium that execute your tests. Like, command - open (URL); Opens the chosen URL in the stated browser and it receives both relative and absolute URLs. An order of Selenium commands (Selenese) collected is known as a test script.

12. Name different ways of finding a web element in Selenium?

In Selenium, web elements are recognized and located by using Locators. They state a target location that exclusively describes the web element in the context of a web application. Therefore, to recognize web elements correctly and precisely we have various types of locators in Selenium:

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

13. Name the types of WebDriver API in Selenium?

  • AndroidDriver
  • ChromeDriver
  • EventFiringWebDriver
  • FirefoxDriver
  • HtmlUnitDriver
  • InternetExplorerDriver
  • iPhoneDriver
  • iPhoneSimulatorDriver
  • RemoteWebDriver

14. Tell some Automation tools that will be integrated with Selenium to attain continuous testing.

Selenium can be used to systematize functional tests by integrating it with automation test tools such as Maven, &Docker, Jenkins, to attain continuous testing. It can also be integrated with tools such as TestNG, &JUnit for handling test cases and creating reports.

15. Explain assertion in Selenium?

The assertion is utilized as a verification point. It confirms the state of the application obeys what is expected. These are types of assertion: “assert”, “verify”, and “waitFor”.

16. Explain assert and verify commands?

Assert: Assert command test whether the given condition is true or false. If the condition is true, the program control will run smoothly to the next phase of testing, and if the condition is false, execution is instantly stopped, and nothing will be executed.

Verify: Verify command also test if the given condition is true or false. It doesn’t stop running the program, it means any failure during verification will not stop the execution, and all the test phases would be executed in a way they are executing.

17. Explain XPath?

XPath is also said XML Path. It is a programming language used to inquire about XML documents. It is a significant approach to discover elements in Selenium. XPath includes a path expression besides some conditions. Here, we can easily type XPath script/query to position any element in the webpage. It is made to enable the navigation of XML documents. The key factors that it well-thought-out while navigating are selecting individual elements, attributes, or some other part of an XML document for particular processing. It also creates reliable locators.

  • XPath is a programming language used for positioning nodes in XML documents.
  • XPath can be used as a substitute when you don’t have an appropriate id or name attribute for the element you want to locate.

18. What do you understand with XPath Absolute and XPath attributes?

XPath Absolute:

XPath Absolute allows users to show the complete XPath location from the root HTML tag to the precise elements.

Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index]

Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]

XPath Attributes:

XPath Attributes are always suggested when you don’t have an appropriate id or name attribute for the element you want to locate.

Syntax: //htmltag[@attribute1='value1’ and @attribute2='value2’]

Example: //input[@id='passwd’ and @placeholder='password’]

19. Differentiate between "/" and "//" in XPath?

Single Slash “/": Single slash creates XPath with absolute path.

Double Slash “//": Double slash creates XPath with the relative path.

20. Tell the types of annotations used in Selenium?

  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith

Know the Interview Criteria of these MNCs!!!

Selenium Interview Questions For Experienced

21. Name the WebDriver that supports Mobile Testing Drivers?

  • AndroidDriver
  • IphoneDriver
  • OperaMobileDriver

22. Name some Selenium WebDriver supporting programming languages to write Test Cases?

  • JAVA
  • PHP
  • Python
  • C#
  • Ruby
  • Perl

23. Differentiate between type keys and type commands?

TypeKeys() will activate JavaScript event in most of scenarios whereas .type() won’t.

24. Differentiate between "typeAndWait" and "type" commands?

“type” command, writes keyboard key values into the text box of the software web application. It also selects values of the combo box however “typeAndWait” command is used after your typing is finished and the software web page starts reloading. This command waits for the software application page to reload. If you have no page reload event on typing, then use a simple “type” command.

25. Differentiate between findElement() and findElements()?

findElement(): To find the first element within the existing page by using “locating mechanism”. It returns one WebElement.

findElements(): To find all the elements within the existing page by using “locating mechanism”. It returns with a list of all web elements.

26. Explain wait and its types?

Selenium Webdriver presents the idea of waiting for the AJAX-based application. Following are the two types of waits:

  • Implicit Wait
  • Explicit Wait

27. Tell the main disadvantage of implicit wait?

It slows down test performance. Another disadvantage is, Assume that you have set the waiting limit to be 10 seconds, and the elements come in the DOM in 11 seconds; your tests will be unsuccessful as you told it to wait a max of 10 seconds.

28. Explain Selenium Grid?

Selenium Grid enables you to allocate your tests on various machines simultaneously. So, you can perform tests on Internet Explorer on Windows and Safari on Mac machines using the same test script. It decreases test execution time and gives quick feedback.

29. Tell the way to launch various browsers in Selenium WebDriver?

Create an instance of a driver of that specific browser.

WebDriver driver =newFirefoxDriver();

Here, “WebDriver” is an interface, and we are generating a reference variable “driver” of type WebDriver, instantiated using “FireFoxDriver” class.

30. Make a code snippet to execute right-click an element in WebDriver.

By using Action class to generate user event like right-click an element in WebDriver.

Actions action = newActions(driver);

WebElement element = driver.findElement(By.id(“elementId”));

action.contextClick(element).perform();

31. Mention a programming code snippet to execute mouse hover in WebDriver.

Actions action = newActions(driver);

WebElement element = driver.findElement(By.id(“elementId”));

action.moveToElement(element).perform();

32. Tell the various methods to refresh a web page in WebDriver?

1. Using driver.navigate command -

driver.navigate().refresh();

2. Using driver.getCurrentUrl() with driver.get() command -

driver.get(driver.getCurrentUrl());

3. Using driver.getCurrentUrl() with driver.navigate() command -

driver.navigate().to(driver.getCurrentUrl());

4. Pressing an F5 key on any textbox using the sendKeys command -

driver.findElement(By textboxLocator).sendKeys(Keys.F5);

5. Passing ascii value of the F5 key, i.e., “\uE035” using the sendKeys command -

driver.findElement(By textboxLocator).sendKeys("\uE035”);

33. Create a code for navigate back and forward in browser history?

Navigate back in browser history:

driver.navigate().back();

Navigate forward in browser history:

driver.navigate().forward();

34. Tell the syntax to invoke an application in WebDriver?

driver.get(“url”); or

driver.navigate().to(“url”);

35. Tell the way to get a text of a web element?

Get command helps us in getting the inner text of the defined web element. It doesn’t need any parameter, but it brings a string type value. It is also one of the most used commands used for the verification of labels, messages, and errors, etc. from web pages.

Syntax

String Text = driver.findElement(By.id(“Text”)).getText();

36. Tell the way to select a value in a dropdown?

We use the WebDriver’s Select class to select values in a dropdown.

Syntax:

selectByValue:

Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));

selectByValue.selectByValue(“greenvalue”);

selectByVisibleText:

Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));

selectByVisibleText.selectByVisibleText(“Lime”);

Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));

selectByIndex.selectByIndex(2);

37. Tell different types of navigation commands?

navigate().back()

This command requires no parameters and returns the user to the previous webpage.

Example

driver.navigate().back();

navigate().forward()

This command permits the user to navigate to the next web page with reference to the browser’s history.

Example

driver.navigate().forward();

navigate().refresh()

This command permits the user to refresh the existing web page by reloading all the web elements.

Example

driver.navigate().refresh();

navigate().to()

This command permits the user to open a new web browser window and navigate to the stated URL.

Example

driver.navigate().to(“https://google.com”);

38. In WebDriver, How to deal with a frame?

An inline frame called iframe is used to add another document within the existing document. This document can be HTML or web page and nested web page.

Select iframe by id

driver.switchTo().frame(“ID of the frame”);

Locating iframe using tagName

driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));

Locating iframe using index

frame(index)

driver.switchTo().frame(0);

frame(Name of Frame)

driver.switchTo().frame(“name of the frame”);

frame(WebElement element)

Select Parent Window

driver.switchTo().defaultContent();

39. Is there an HtmlUnitDriver for .NET?

To use HtmlUnit first use the RemoteWebDriver and pass it in the anticipated capabilities.

IWebDriver driver

= new RemoteWebDriver(DesiredCapabilities.HtmlUnit())

For the Firefox implementation to run, use

IWebDriver driver

= new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript())

40. Show an example of redirect browsing from a browser through some proxy?

Example

String PROXY = “199.201.125.147:8080”;

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

proxy.setHTTPProxy(Proxy)

.setFtpProxy(Proxy)

.setSslProxy(Proxy)

DesiredCapabilities cap = new DesiredCapabilities();

cap.setCapability(CapabilityType.PROXY, proxy);

WebDriver driver = new FirefoxDriver(cap);

41. Explain POM (Page Object Model) and its advantages?

Page Object Model (POM) is a design pattern for making an Object directory for web User Interface elements. Every web page is necessary to have its page class. The page class is accountable for finding the WebElements in web pages and then implements operations on WebElements.

The advantages of using POM are.

  • It enables separate operations and flows in the UI from Verification - increases code readability
  • Numerous tests can use the same Object Repository as the Object Repository is independent of Test Cases.
  • Reusability of code

42. Tell the instructions to capture screenshot 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.openqa.selenium.OutputType;

import org.openqa.selenium.TakesScreenshot;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class TakeScreenshot {

WebDriver drv;

@Before

public void setUp() throws Exception {

driver = new FirefoxDriver();

drv.get(“https://google.com”);

}

@After

public void tearDown() throws Exception {

drv.quit();

}

@Test

public void test() throws IOException {

//capture the screenshot

File scrFile = ((TakeScreenshot)drv).getScreenshotAs(OutputType.FILE);

// paste the screenshot in the desired location

FileUtils.copyFile(scrFile, new File(“C:\\Screenshot\\Scr.jpg”))

}

}

43. How to enter the string in a textbox using Selenium?

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

Syntax

WebElement username = drv.findElement(By.id(“Email”));

// entering username

username.sendKeys(“sth”);

44. Tell the method to find if an element is shown on the screen?

WebDriver enables user to test the visibility of the web elements. These elements can be radio buttons, boxes, buttons, checkboxes, drop, labels etc. that can be used with the following methods.

  • isDisplayed()
  • isSelected()
  • isEnabled()

Syntax:

isDisplayed():

boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();

isSelected():

boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isSelected();

isEnabled():

boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();

driver.findElement(By.linkText(“Google”)).click();

The given command searches for the element by using a link text, then clicks on that element, and then the user is redirected to the matching page.

driver.findElement(By.partialLinkText(“Goo”)).click();

The given command looks for the element based on the substring of the link given in the parenthesis. And after that partialLinkText() discovers the web element with the stated substring and then clicks on it.


Want to prepare for these languages:

Recent Articles