Selenium
Selenium Interview Q&A
(SET-1)
How do you get the window title in Selenium?
How do you switch to the new window?
How do you switch back to the default window?
Difference between quit and close in Selenium?
How many types of exceptions are there in Selenium?
How do you handle StaleElementReferenceException and does it
belong to Selenium or Java?
Difference between findElements and findElement?
Types of Selenium waits?
Difference between Explicit and Fluent wait?
Which method do you use to get all dropdown values in Select
class?
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
1. How do you get the window title in Selenium?
Use driver.getTitle() to get the title of the current window.
2. How do you switch to the new window?
Get all window handles using driver.getWindowHandles().
Switch to the new window using driver.switchTo().window(windowHandle), where
windowHandle is the handle of the new window.
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
3. How do you switch back to the default window?
Store the original window handle before opening a new window.
Use driver.switchTo().window(originalWindowHandle) to switch back to the
default window.
4. Difference between quit and close in Selenium:
“driver.close()” closes the current browser window.
“driver.quit()” closes all browser windows and ends the WebDriver session.
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
5. How many types of exceptions are there in Selenium?
Selenium has several exceptions such as
NoSuchElementException
TimeoutException
StaleElementReferenceException
ElementNotInteractableException
NoSuchFrameException
NoSuchWindowException
InvalidSelectorException
WebDriverException
ElementNotFoundException
ElementClickInterceptedException
NoSuchAttributeException
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
6. How do you handle StaleElementReferenceException and does it belong to
Selenium or Java?
To handle StaleElementReferenceException, you can try re-locating the
element or using a retry mechanism.
It is a Selenium exception but it can be caught using Java exception handling
(try-catch).
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
7. Difference between findElements and findElement?
findElement returns a single WebElement matching the locator.
findElements returns a list of WebElements matching the locator. If no elements
are found, it returns an empty list.
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
8. Types of Selenium waits?
Implicit Wait: Automatically applies a wait time to find elements if they are not
immediately available.
Explicit Wait: Waits for a specific condition to be met before proceeding.
Fluent Wait: Similar to explicit wait but allows for more flexibility with polling
intervals and exception handling.
9. Which method do you use to get all dropdown values in Select class?
Use select.getOptions() to get a list of all options in a dropdown.
Qa_Navigators
Selenium
Selenium Interview Q&A
(SET-1)
10. Difference between Explicit and Fluent Wait:
Explicit Wait: Waits for a condition to be true for a specified amount of time. If the
condition is not met, a TimeoutException is thrown.
Fluent Wait: A type of explicit wait with additional options, such as customizing the
polling interval and ignoring specific exceptions.
Qa_Navigators