Prepare for your Selenium interview with these 30 carefully curated questions and answers. Covering basic, intermediate, and advanced topics, this guide helps freshers, candidates with 1-3 years of experience, and professionals with 3-6 years of experience master Selenium concepts for web automation testing.
Basic Selenium Interview Questions
1. What is Selenium?
Selenium is an open-source suite of tools for automating web browsers. It supports writing test scripts in various programming languages to perform actions like clicking, typing, and navigating web pages across different browsers.[2][3]
2. What are the main components of the Selenium Suite?
The Selenium Suite includes Selenium IDE for recording tests, Selenium WebDriver for browser automation, and Selenium Grid for parallel execution. Selenium RC is deprecated and replaced by WebDriver.[2]
3. Which locator is the fastest and which is the slowest in Selenium?
ID is the fastest locator, while XPath is the slowest due to its parsing complexity.[1]
4. What is the difference between findElement() and findElements()?
findElement() returns a single WebElement or throws an exception if not found. findElements() returns a list of WebElements, returning an empty list if none are found.[3]
5. What are implicit waits in Selenium?
Implicit waits set a default timeout for all element searches, polling until the element is found or the timeout expires.[1][3]
6. What are explicit waits in Selenium?
Explicit waits use WebDriverWait with ExpectedConditions to wait for a specific condition on an element, like visibility or clickability.[1][3]
7. What is the difference between close() and quit() methods?
close() closes the current browser window. quit() closes all browser windows and ends the WebDriver session.[1]
8. How do you launch a browser in Selenium?
Set system properties for the driver executable and instantiate the WebDriver class, such as ChromeDriver for Chrome or FirefoxDriver for Firefox.[6]
9. What is driver.get() vs driver.navigate().to()?
Both navigate to a URL, but driver.get() blocks until the page loads fully, while driver.navigate().to() is faster and supports browser history.[1]
10. How do you verify the title of a web page?
Use driver.getTitle() and assert it against the expected title string.[1]
Intermediate Selenium Interview Questions
11. What is Fluent Wait in Selenium?
Fluent Wait allows defining the maximum wait time and polling frequency for a condition, ignoring specific exceptions during waits.[1][3]
12. How do you handle frames in Selenium?
Switch to a frame using driver.switchTo().frame() by index, name, or ID, and switch back with driver.switchTo().defaultContent().[1]
13. How do you perform mouse hover and keyboard actions?
Use ActionChains class for mouse actions like hover and drag-and-drop, and Keys enum for keyboard inputs like ENTER or TAB.[1]
14. Can Selenium automate desktop applications?
No, Selenium only supports web browser automation.[1]
15. How do you handle alerts in Selenium?
Switch to the alert with driver.switchTo().alert(), then use accept(), dismiss(), or getText().[3]
16. What is the Page Object Model (POM) in Selenium?
POM is a design pattern where web pages are represented as classes, and elements/locators are separated from test logic for better maintainability.[2][3]
17. How do you implement Page Object Model?
Create a page class with WebElement locators as fields and methods for actions, then use page instances in test classes.[2]
18. What are Soft Assertions in Selenium?
Soft assertions allow tests to continue after a failure, collecting all failures, unlike hard assertions that stop execution immediately.[3]
19. How do you take screenshots in Selenium?
Use ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE) and save the file.[3]
20. What is Selenium Grid?
Selenium Grid enables parallel test execution across multiple machines and browsers by connecting nodes to a hub.[2]
Advanced Selenium Interview Questions
21. How do you handle dynamic elements in Selenium at Zoho?
At Zoho, for dynamic web elements, use XPath with contains() or starts-with() functions to match partial attributes reliably.
driver.findElement(By.xpath("//button[contains(text(),'Submit')]"));
[1][3]
22. Explain handling broken links in Selenium.
Collect all links with findElements(By.tagName(“a”)), then use HttpURLConnection to check response codes for 200 status.[1]
23. How do you perform data-driven testing in Selenium?
Read test data from Excel, CSV, or databases externally and parameterize tests to run with multiple datasets.[1]
24. What are headless browsers in Selenium?
Headless mode runs browsers without UI, using ChromeOptions.setHeadless(true) for faster CI/CD execution.[3]
25. How do you optimize Selenium test performance at Paytm?
At Paytm, optimize by using explicit waits, avoiding sleep(), minimizing locators, and running parallel tests with Grid.[2]
26. Describe handling multiple windows in Selenium.
Get window handles with driver.getWindowHandles(), switch using driver.switchTo().window(handle).[3]
27. Can Captcha be automated with Selenium?
No, Captcha requires human input; Selenium can fill other fields but needs manual intervention for Captcha.[3]
28. How do you handle Shadow DOM in Selenium at Salesforce?
At Salesforce, use JavaScriptExecutor to pierce Shadow DOM: driver.executeScript(“return document.querySelector(‘host’).shadowRoot.querySelector(‘selector’)”).[3]
29. What is a hybrid framework in Selenium?
A hybrid framework combines data-driven and keyword-driven approaches for flexible, reusable test automation.[4]
30. How would you automate a complex dropdown scenario at Atlassian?
At Atlassian, for custom dropdowns, use Actions to click, scroll with JavaScript if needed, and select via visible text or index.
Actions actions = new Actions(driver); actions.moveToElement(dropdown).click().perform();
[1][3]