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?


5. Write a code to select a value from the dropdown?

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 addons in firefox, to generate the xpaths easily. These addons are available only in firefox browser.





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 *