50 Selenium Interview Questions To Ace Your Next Interview

50 Selenium Interview Questions To Ace Your Next Interview

Wondering what you need to know when preparing for the selenium interview? Read this guide to learn all about selenium interview questions and answers

Software testing is one of the most critical phases of the software development life cycle (SDLC). Specifically, manual testing involves the physical execution of test cases against applications to detect bugs and errors. However, manual testing presents several challenges, and there is an urgent need for an automated approach. Eventually, this led to the invention of the powerful automated testing tool, Selenium. Therefore, getting a job in the selenium field is a plus, and being able to ace your selenium interview will prove invaluable.

This guide contains all the required Selenium interview questions for experienced and Selenium interview questions for freshers to prepare. Those who are anticipating a Selenium interview should review these top 50 frequently asked Selenium interview questions.

Selenium is one of the most popular tools for testing web-based applications. Therefore, it is highly beneficial to learn Selenium.

The most comprehensive and up-to-date Selenium Interview Questions and Answers

This ebook contains a collection of Selenium Interview Questions and Answers. This ebook is written in simple language and is very easy to understand. This is what you need to take a Selenium interview.

1. What is meant by Selenium Suite and what are its different components?

Answer: Selenium is a package of different testing tools and is often referred to as a Selenium Suite, with each tool designed to satisfy a specific testing requirement. Selenium Suite consists of the following components:

  • Selenium Integrated Development Environment (IDE): This plug-in is used to automate web browser tasks by recording the actions of users and exporting the scripts as reusable script files.
  • Selenium Remote Control (RC): Using this server, users can generate test scripts in any language they prefer. It accepts commands from test scripts and sends them to the browser as Selenium core JavaScript commands so that the browser will act accordingly.
  • Selenium WebDriver: A programming interface that allows you to automate test cases by directly communicating with the web browser and using its native compatibility. It doesn't require an additional server to create and run test cases, unlike RC.
  • Selenium Grid: Distributes commands across a network of machines to allow parallel execution of tests on different browsers and operating systems.

2. How will you find an element using Selenium?

Answer: In Selenium, every object or control on a web page is referred to as an element. There are different ways to find elements on a web page they are:

  • Tag
  • Attribute
  • CSS
  • PartialLink Text
  • Xpath etc
  • ID
  • Name
  • Linktext

3. Mention the types of Web locators.

Answer: Selenium IDE uses the locator command to determine which GUI elements (such as text boxes, buttons, checkboxes, etc) to operate on. Localizers specify an area of action.

  • Locator by ID: It takes a string parameter that specifies the value of the ID attribute, and returns the object to findElement().


  • Locator by the link: To locate an element that has a link text, you can use the by.linkText locator.

driver.findElement(By.linkText(“Today’s deals”)).click();

  • Locator by Partial link: You can locate a targeted link by using a portion of its text.


  • Locator by Name: The first element whose name attribute matches the location is returned.


  • Locator by TagName: Retrieves all elements with the same tag name.


  • Locator by classname: By using the CLASS attribute, it finds elements. The element will be compared against all its classes if it has more than one.


  • Locator by XPath: It takes a String parameter, which is an XPATHEXPRESSION, and returns an object to the findElement() method.

    driver.findElement(By.xpath(“//span[contains(text(),’an account’)]”)).getText();

  • Locator by CSS Selector: It locates elements based on the underlying CSS selector engine of the driver.


4. What is meant by Selenese? Explain different types of Selenium commands.

Answer: Selenese is the code language used in the Selenium IDE for writing test scripts. Essentially, it's a set of command lines you use to test your web application. There are three main categories of Selenium commands:

  • Actions: These are commands that interact directly with web applications.
  • Accessors: These are commands that allow users to store values in a user-defined variable.
  • Assertions: They enable the application to be compared with its expected state.

5. What are the advantages of Selenium?

Answer: Selenium offers the following advantages:

  • Selenium is open-source software. Anybody can download the source code and use or modify it according to the company's needs.
  • Google's developer community supports it.
  • There are powerful methods for finding elements (Xpath, DOM, CSS).
  • Supported languages include C#, PHP, Java, Perl, and Python.
  • Windows, Linux, and Mac OS are supported.

6. What are the disadvantages of using Selenium as a testing tool?

Answer: Selenium has the following disadvantages as a testing tool:

  • No built-in reporting and test management facility: Selenium can only generate reports by using third-party tools such as TestNG or JUnit.
  • May require the knowledge of programming languages: To use Selenium, you need some programming skills.
  • Tests web applications only: Web applications are the only ones that Selenium can test. Mobile applications, Captchas, and barcode readers cannot be tested with Selenium unless they are integrated with third-party tools like Appium and TestNG.
  • Unavailability of reliable tech support: Since Selenium is an open-source tool, it does not have dedicated support for user issues.

7. What is the Same Origin policy? How can you avoid the same-origin policy?

Answer: The "Same Origin Policy" was introduced for security reasons and ensures that scripts from another website will never be able to access the content of your site. Under the policy, any code loaded in a browser can only be executed within the domain of the website it was installed on.

The proxy injection is used to avoid "Same Origin Policy". In proxy injection mode, Selenium acts as a client-configured HTTP proxy, which sits between the browser and the application under test, masking the AUT under a fictional URL.

8. Why should Selenium be selected as a testing tool for web applications or systems?

Answer: Selenium is an excellent automated testing framework due to the following advantages:

  • The software is open-source, free, and has a large community behind it.
  • Multiple browsers are compatible with it, including Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, and Safari.
  • Multi-OS support, including Windows, Linux, and macOS.
  • Selenium facilitates the use of multiple programming languages such as Scala, Ruby, Python, PHP, Perl, Java, Groovy, C#, etc.
  • Additionally, it supports distributed testing.

9. What is automation testing, and what are its advantages?

Answer: The goal of automation testing or test automation is to automate the manual testing process of an application or a system using testing tools that allow you to create scripts that can be executed repeatedly and generate detailed test reports.

Automated testing has the following advantages:

  • It can be used to test both the performance and the functionality of an application or system.
  • It helps the execution of repeated test cases.
  • Parallel execution of test cases is possible.
  • It improves the accuracy and efficiency of the system by reducing the amount of human intervention required.
  • Using it can help you test a large test matrix.
  • As a result, the testing team involved in the project saves time and money.

10. What is meant by an exception test in Selenium?

Answer: Tests that expect to throw an exception inside a test class are exception tests. The annotation @Test is followed by the expected exception name in brackets. For example:

@Test(expectedException = NoSuchElementException.class) is an exception test for missing elements in Selenium.

11. State the major difference between “assert” and “verify” commands in Selenium.

Answer: "Assert" and "Verify" both check if the given condition is true or false, and the only difference between them is:

  • Assert: If the given condition is false, the testing is stopped. Otherwise, it continues.
  • Verify: Make sure the condition doesn't affect execution flow, whether it is true or false.

12. Can selenium be used to launch web browsers?

Answer: Yes, Selenium supports launching web browsers, including Google Chrome, Mozilla Firefox, Internet Explorer, etc. Selenium can be used to launch web browsers using the following commands:

  • WebDriver driver = new FirefoxDriver();
  • WebDriver driver = new ChromeDriver();
  • WebDriver driver = new InternetExplorerDriver();

13. What is meant by XPath in Selenium?

Answer: XPath, or XML-Path (Extensible Markup Language Path), is a specification language for querying XML documents and locating elements through Selenium by iterating through each element of the webpage. XPath stores data as key-value pairs, similar to HTML tags. It uses a single slash (/) to create an absolute path, and a double slash (//) to create a relative path for an element located on a page.

14. Explain the difference between findElement() and findElements() in Selenium.

Answer: In general, these two commands differ significantly:

  • findElement(): This command is used to locate a particular element on a web page, returning the object of the first element located by the locator.

Example: WebElement element = driver.findElement(By.id(example));

  • findElements(): Using this command, you can find all the elements on a webpage specified by the locator value. All matching web elements are returned by this command.

Example: List <WebElement> elementList = driver.findElements(By.id(example));

15. Explain the difference between the driver.close() and driver.quit() commands in Selenium?

Answer: In a nutshell, both commands differ in the following ways:

  • The driver.close() command closes the window in which the user is currently working or the window currently being accessed by the web driver.
  • The driver.quit() command, unlike the driver.close() command, closes all the windows open by the program, and therefore should be used with caution.

Both commands don't take any parameters, and neither return any values either.

16. Explain the various navigation commands supported by Selenium?

Answer: There are four main navigation commands supported by Selenium:

  • navigate().back(): You can use this command to take the user to the last webpage in the browser history.
  • navigate().forward(): You can use this command to move to the next page in the browser history.
  • navigate().refresh():Using this command, you can refresh a web page's web components.
  • navigate().to(): In a new web browser, this command is used to navigate to a specific URL. It takes the URL to migrate to as a parameter.

17. Mention the difference between Implicit wait and Explicit wait?


Implicit Wait: Sets a timeout for all subsequent searches of the Web Element. During that period, it will keep trying to find elements until a NoSuchElementException is thrown. It waits for elements to appear.

Explicit Wait: This is a one-timer, used for a particular search.

18. Which attribute should be considered throughout the script in the frame for "if no frame Id as well as no frame name"?

Answer: This can be done by using driver.findElements(By.xpath("//iframe"))....

The following command returns a list of frames. Every frame must be switched to find the locator we are looking for. After that, break the loop.

19. How you can use “submit” a form using Selenium?

Answer: To submit a form, use the "submit" method on an element - element.submit () ;

Additionally, you can click on the element that submits the form.

20. Name some of the commonly used Automation Testing tools that are used for Functional Automation.

Answer: The following are lists of the top 10 automation testing tools for Functional Automation.

  1. Developed by Telerik, the Telerik Test Studio.
  2. Selenium, open-source.
  3. Rational Robot, provided by IBM.
  4. Auto It, Open Source.
  5. TestingWhiz
  6. Tosca Testsuite
  7. HPE Unified Functional Testing (HP - UFT formerly QTP)
  8. Watir
  9. Coded UI, provided by Microsoft.
  10. Quick Test Professional, provided by HP.

21. What is the difference between type keys and type commands?

Answer: In most cases, TypeKeys() will trigger JavaScript events, while .type() will not.

Answer: Test Cases can be written using Selenium WebDriver in the following languages:

  • C#
  • Pearl
  • Ruby
  • Java
  • Python
  • PHP

23. What is the difference between the "type" and "typeAndWait" command?

Answer: Using the type command, you can type keyboard key values into the text box of a software web application. This command can also be used to select values from the combo box, while "typeAndWait is used when the software web page is about to reload after you have finished typing. Upon running this command, the software application page will reload. You must use the type command if the browser doesn't reload after typing.

24. What is Selenium IDE?

Answer: As an extension for Firefox, Selenium IDE provides record and playback functionality on test scripts. It allows testers to export recorded scripts in a variety of languages like HTML, Java, Ruby, RSpec, Python, C#, TestNG, and JUnit.

A limitation of Selenium IDE is that it does not generate very robust, or portable, test scripts.

25. List out some of the automation tools which could be integrated with Selenium to achieve continuous testing.

Answer: To achieve continuous testing, Selenium can be integrated with tools such as Maven, Jenkins, and Docker for automating functional tests. Additionally, it can be integrated with tools such as TestNG & JUnit to manage test cases and generate reports.

26. How many types of WebDriver APIs are available in Selenium?

Answer: WebDriver APIs used to automate browsers include:

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

27. Explain XPath Absolute and XPath attributes.


XPath Absolute: The XPath Absolute feature allows users to specify the XPath location from the root HTML tag to specific 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 When you don't have an appropriate id or name attribute for the element you want to locate, you should always use XPath Attributes.

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

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

28. What are the WebDriver supported Mobile Testing Drivers?

Answer: The following "mobile testing drivers" are supported by WebDriver:

  • IphoneDriver
  • OperaMobileDriver
  • AndroidDriver

29. What is the difference between "/" and "//" in XPath?


  • Single Slash "/": You can create XPath with an absolute path by using the single slash.

  • Double Slash "//": For relative paths, double slashes are used.

30.What are the different types of annotations which are used in Selenium?

Answer: The following JUnit annotations can be used:

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

31. What is the wait? How many types of waits in selenium?

Answer: Selenium Webdriver introduces the concept of waits for AJAX-based applications. Selenium automation consists of three types of waits:

  • Implicit Wait
  • Explicit Wait
  • Fluent Wait

32. What is the main disadvantage of implicit wait?

Answer: Slow test performance is the main disadvantage of implicit wait. Implicit waiting also has the disadvantage of:

In the example given, you set the waiting limit to 10 seconds, and elements appeared in the DOM after 11 seconds. As a result, your tests will fail because you told them to wait a maximum of 10 seconds.

33. How can we launch different browsers in Selenium WebDriver?

Answer: An instance of the driver must be created for that particular browser.

WebDriver driver =newFirefoxDriver();

Here, "WebDriver" is an interface, and we are creating a reference variable "driver" of type WebDriver, which we instantiate with the "FireFoxDriver" class.

34. What is Selenium Grid?

Answer: The Selenium Grid enables you to run your tests simultaneously on multiple machines. Using the same text script, you can run tests on Internet Explorer on Windows and Safari on Mac machines. It reduces the time of test execution and provides fast feedback.

35. How can we get a text of a web element?

Answer: Using the Get command, you can get the inner text of a web element. Get does not require any parameters, but it returns a string type value. Additionally, it is one of the most widely used commands for verifying messages, labels, and errors on web pages.

Syntax: String Text = driver.findElement(By.id("Text")).getText();

36. What are the different types of navigation commands?

Answer: There are four types of navigation commands:

  • navigate().back() - This command requires no parameters and returns the user to the previous page.

Example: driver.navigate().back();

  • navigate().forward() - Using this command, the user can navigate to the next web page regarding the browser's history.

Example: driver.navigate().forward();

  • navigate().refresh() - The navigate().refresh() command allows the user to reload all the web elements of the current page.

Example: driver.navigate().refresh();

  • navigate().to() - The navigate().to() command launches a new web browser window and navigates to the specified URL.

Example: driver.navigate().to("https://google.com");

37. Is there an HtmlUnitDriver for .NET?

Answer: HtmlUnit is implemented by first using a RemoteWebDriver and then passing the desired capabilities to it.

IWebDriver driver  
= new RemoteWebDriver(DesiredCapabilities.HtmlUnit())
  • To run in Firefox, you must use
IWebDriver driver  
= new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript())

38. What is POM (Page Object Model)? What are its advantages?

Answer: Page Object Model is a design pattern for making an Object directory for web user interface elements. Every web page must have a page class. Page classes are responsible for finding WebElements in web pages and then performing operations on them. The advantages of using POM are as follows:

  • Reusability of code
  • UI operations and flows can be separated from Verification - improving code readability.
  • Since Object Repositories are independent of Test Cases, multiple tests can use the same Object Repository.

39. How can you find if an element is displayed on the screen?

Answer: Users can check the visibility of web elements using WebDriver. Web elements include buttons, radio buttons, dropdown menus, boxes, labels, as well as checkboxes.

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

Answer: driver.findElement(By.linkText("Google")).click();

By using the link text in the above command, the user can search the element and click on it, so the user is redirected to the corresponding page. Using the following command, you can access the link mentioned earlier.


Using the above command, the element will be searched according to the substring in the link provided within the parenthesis. Then partialLinkText() finds the web element that contains the specified substring and clicks on it.

41. Explain what are the JUnits annotation linked with Selenium?

Answer: JUnits annotations linked to Selenium are

  • @ Before public void method() – It will perform the method () before each test, this method can prepare the test.
  • @ Test public void method() – Annotations @Test identifies that it is a test method environment.
  • @ After public void method()- To perform a test before this annotation is used, the test method must begin with test@Before.

42. What is Object Repository?

Answer: Object repositories are a vital component of UI automation, allowing a tester to store objects that will be used in the scripts in one or more centralized locations rather than scattered across multiple scripts.

43. Explain how you can handle colors in a web driver?

Answer: Colors can be handled in the web driver using the getCssValue(arg0) function by sending the ‘color’ string as the argument.

44. Mention 5 different exceptions you had in the Selenium web driver?

Answer: Selenium web drivers gave you five different exceptions:

  • TimeoutException
  • WebDriverException
  • NoSuchWindowException
  • NoSuchElementException
  • NoAlertPresentException

45. What are heightened privileges browsers?

Answer: In the same way that Proxy Injection permits websites to do things they would normally not be allowed to do, heightened privileges allow websites to do things that would not normally be allowed. It is important to note that the browsers are launched in a special mode called heightened privileges. These browser modes allow Selenium core to open the AUT directly and read/write its content without passing the whole AUT through Selenium RC.

46. List the advantages of Webdriver over Selenium Server?

Answer: These are the few advantages of Webdriver over Selenium server:

  • If you are using Selenium-WebDriver, you don’t need the Selenium Server as it uses different technology.
  • Selenium Server provides Selenium RC functionality, which enables Selenium 1.0 backward compatibility.
  • Selenium Web driver uses native automation support in each browser, whereas Selenium RC requires a Selenium server to inject Javascript into the browser.

47. Explain how you can find broken images on a page using Selenium Web driver?

Answer: Using Selenium web driver, find the broken images on a web page

  • Get XPath and use a tag name to get all the links on the page.
  • Click on every link on the page.
  • In the target page title, look for 404/500.

48. What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?

Answer: TestNG is a testing framework that simplifies a broad range of testing needs, from Unit Testing to Integration Testing. The functionality that makes it an efficient testing framework is

  • Annotations support
  • Supports data-driven testing
  • Flexible test configuration
  • The ability to re-run failed tests.

49. Mention what are the capabilities of Selenium WebDriver or Selenium 2.0?

Answer: If you need improved support for WebDriver, you should use it

  • Several frames, pop-ups, and multiple browser windows can be handled.
  • Drag & Drop and Page navigation
  • Ajax based UI elements
  • Test across multiple browsers, including improved functionality for browsers not well supported by Selenium 1.0.

50. Explain what is Data-driven and Keyword driven framework.


Data-driven Framework: Using this framework, test data is kept separate from Test Scripts, while Test Case logic is housed in the Test Scripts. The data for the tests are taken from external files (Excel Files) and loaded into variables within the Test Script. For input and verification, variables are used.

Keyword-driven framework: Keyword-driven frameworks require the development of data tables and keywords, independent of test automation. This type of test is based on the keyword and includes step-by-step instructions describing how to complete the test.

If you have made it this far, then certainly you are willing to learn more about software testing. Here are some more resources related to software testing that we think will be useful to you.

Did you find this article valuable?

Support Yash Tiwari by becoming a sponsor. Any amount is appreciated!