Top 25 selenium interview questions

Selenium Interview Questions:

1 Explain Asset and Verify commands in selenium?

Assert and Verify commands are used to verify the presence of an element like text, button, dropdown or link etc., in the UI.

Assert: If a particular element is not present in the UI, then the test will abort immediately.

Verify:  If a particular element is not present in the UI, then the test will not abort and it will proceed to the next steps, and it logs a failure.

2. What is selenese?

Selenese means Selenium commands. These commands are of three types.

Actions: These are used to modify the web application state. Using actions, we can make selenium wait for a particular element, clickAndWait or hover on the dropdown.

Example for Actions in Selenium WebDriver:



Accessors: These are used to analyze the web application state and are used to store the results in variables.


storeAllWindowTitles (varName) – Stores all window titles opened in browser and returns in the form of an array.

storeText (Elemlocator, varName) – Stores the text of any web element which has text.

storeTitle (variableName) – Stores the title of the currently opened page.

Assertions: Are of three types.

  • assert
  • verify
  • waitFor


3. Difference between final, finally and finalize keywords?


Final is the keyword used in java to store a value which is constant (You cannot change the value).

Finally is a block in selenium to execute important test code. Finally block will always get executed even if there is an exception occurred. For example, In trycatchfinally block, exception has occurred in try block. Catch block will handle the exception and then the finally block will get executed.




i/0 is not possible.

finally block excuted.

Finalize() method is used for garbage collection or clean up process.

4. Different types of locators in Selenium?

Ans: Click here to see the different types of locators used in selenium

5. Write a code to select a value from the drop down?

Ans: Click here to know how to select a drop down in selenium webdriver.

6. Difference between relative and absolute xpath?**

Ans: “/” means absolute xpath and “//” is used for relative xpath.

In absolute xpath, xpath of an element is retrieved from the root of the element. So even if a small change in the path of the element can make the test script failure.

Ex: html/body/div[1]/header/nav/ul/li[5]/ul/li[1]/a

In relative xpath, nearby id or attribute is used to generate the xpath. So the chances of element id changes are very less. Due to this reason, relative xpath is preferred over absolute xpath.

Ex: .//*[@id=’menu-item-356′]/a

Note: Install firebug and firepath add-ons in firefox, to generate the xpath easily. These add-ons are available only in firefox browser.

7. FirefoxDriver is a class or an interface?

FirefoxDriver is a class that has been written specifically for the firefox browser. It has methods that are implemented and it can be instantiated. It can perform all methods on the firefox browser as defined in the interface WebDriver. Hence firefoxDriver is a java class and it implements the WebDriver interface.

8. Is there any super interface for WebDriver?
SearchContext is the super interface of Web Driver.

9. What is Fluent Wait in Selenium? How it is different from explicit wait?

FluentWait is different from explicit wait. Fluent wait is used to define the maximum amount of time for
webdriver to wait for a specific element to appear or display and with polling frequency to check for the condition. If the element appears in 2nd sec itself then it won’t check further and continues with further steps. Where as in explicit wait, webdriver waits till 10 sec are completed to check for the condition.

For example, if we give fluent wait as 10 sec and polling frequency as 1 sec, it checks for the condition for every 1 sec for 10 times.

10 Can we mix both implicit wait and explict wait together? If not, why?

Ans: It is not a good practice to mix both implicit and explicit waits together as per selenium official website documentation. Because it may give unpredictable wait times.

Explicit wait can be used when an element takes more than expected time to appear. Explicit wait is applicable for this element only. Where as implicit wait is defined only once in the code it is applicable for whole cycle.

Explicit wait is a conditional wait and it takes priority over implicit wait.

11. How to press ENTER key in selenium.

12. How to navigate back and forth of the page in selenium webdriver?


Recommended Posts:

Real-time selenium interview questions




Tags: selenium qa testing, selenium tutorials, selenium interview questions for experienced, selenium automation testing, top selenium interview questions, handle untrusted ssl certificate in selenium

Leave a Reply

Your email address will not be published. Required fields are marked *