Important Selenium Interview Questions

Arka Sarkar
2 min readOct 20, 2021

So recently I have started learning Selenium for some office work. And I am preparing some interview questions.I will keep track of those here.

Photo by Domenico Loia on Unsplash
  1. How to validate CSS and Xpath in Selenium?

Ans: We can write a two simple commands in browser console to validate xpath. for xpath validation we can write —

$x(“//tagname[@attribute=’value’]”)

and for CSS we can write —

$$(“tagname[attribute=’value’]”)

Note — Using xpath we can traverse to parent elements but this is not possible for css selector.

2. What is By in Selenium?

Ans: By is a class, abstract class to be precise.

3. What are the advantage and disadvantages of implicit wait?

Ans: As implicit wait is global ( as it is applied for all the lines of a code) it is much more readable as we write the code for implicit wait only once. But implicit wait hides the performance issues of the website being tested.

4. What are the pros and cons of explicit wait?

Ans: Explicit wait is only applied for a specific line, so performance issues decreases. but it increases the number of lines of codes.

5. What is the difference between Explicit Wait and Fluent Wait in Selenium?

Ans: Explicit wait is used using the WebDriverWait class which implements the Wait interface. FluentWait is another class which also implements the Wait interface.

In case of FluentWait, there is duration of time defined by us by which fluentwait waits for elements to appear or become clickable in a webpage.

In case of ExplicitWait, the methods for waiting are already defined — like visibilityOfElementLocated(), but in case of Fluent wait, we have to define the methods by ourselves.

6. How multiple windows are handled in selenium?

Ans: To handle multiple windows in Selenium we use driver.switchTo().window(<id of the window>) as the driver does not automatically moves to the newly opened windows. To get the id of the window, we use the command driver.getWindowHandles which returns a set of ids of windows and we need to iterate through it for getting our required child window id.

--

--

Arka Sarkar

Bengali Guy, shy, awkward, full of anxiety. I write about the solutions of the problem I face in my life. Trying to become a Software Developer