0% found this document useful (0 votes)
16 views6 pages

30 Selenium Interview Questions

Interview guide

Uploaded by

errpporwal98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

30 Selenium Interview Questions

Interview guide

Uploaded by

errpporwal98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

30 Selenium Interview Questions Every

QA Should Know
Doc By Aston Cook

These questions cover the most practical Selenium topics for UI automation interviews.

1. What is Selenium?

Answer: Selenium is an open-source suite of tools used for automating web browsers. It
supports multiple languages (Java, Python, C#, etc.) and provides browser compatibility across
Chrome, Firefox, Safari, and more.

2. What are the main components of Selenium?

Answer:

●​ Selenium WebDriver​

●​ Selenium IDE​

●​ Selenium Grid​

3. What is Selenium WebDriver?

Answer: WebDriver is the main automation component in Selenium. It provides APIs to control
browser behavior and interact with elements.

4. What browsers does Selenium support?

Answer: Chrome, Firefox, Edge, Safari, Opera, and headless browsers like HtmlUnitDriver.
5. What’s the difference between findElement() and findElements()?

Answer:

●​ findElement() returns a single WebElement and throws an exception if not found.​

●​ findElements() returns a list of WebElements and returns an empty list if none are found.​

6. How do you handle dynamic web elements?

Answer: Use stable locators like CSS selectors or XPath with contains, starts-with, or regular
expressions. Avoid using changing attributes like timestamps or session IDs.

7. What is the difference between XPath and CSS Selector?

Answer:

●​ XPath can navigate both forward and backward in the DOM.​

●​ CSS selectors are generally faster and easier to read, but cannot traverse up the DOM.​

8. How do you handle waits in Selenium?

Answer: Implicit Wait. Explicit Wait (WebDriverWait with ExpectedConditions). Fluent Wait. Use
waits to handle elements that load asynchronously.​

9. What is the Page Object Model (POM)?

Answer: A design pattern that helps organize code by separating page elements and logic into
reusable classes. It improves maintainability and scalability.

10. How do you take a screenshot in Selenium?


Answer: Use TakesScreenshot interface and call getScreenshotAs() method.

11. How do you handle dropdowns?

Answer: Use the Select class and its methods like selectByVisibleText(), selectByValue(), and
selectByIndex().

12. How do you perform mouse and keyboard actions?

Answer: Use the Actions class to handle mouse hovers, drag-and-drop, clicks, and keyboard
keys.

13. How do you switch between browser tabs?

Answer: Use getWindowHandles() and switchTo().window(handle) to change tabs.

14. How do you switch to a frame in Selenium?

Answer: Use [Link]().frame() with index, name, or WebElement.

15. What are some common exceptions in Selenium?

Answer:

●​ NoSuchElementException​

●​ TimeoutException​

●​ ElementNotInteractableException​

●​ StaleElementReferenceException​
16. How do you handle alerts?

Answer: Use [Link]().alert() and call accept(), dismiss(), or getText().

17. Can Selenium be used for testing mobile apps?

Answer: Not directly. For mobile apps, use Appium, which extends Selenium for mobile
automation.

18. How do you run tests in parallel?

Answer: Use Selenium Grid or integrate with TestNG/JUnit to run parallel test classes and
methods.

19. How do you scroll down a page in Selenium?

Answer: Use JavaScriptExecutor to run [Link]() or [Link]().

20. How do you upload a file in Selenium?

Answer: Use sendKeys() to send the absolute file path to an <input type="file"> element.

21. What is a headless browser and how do you use it?

Answer: A headless browser runs without a GUI. Configure ChromeOptions or FirefoxOptions to


run in headless mode.

22. How do you validate broken links?

Answer: Get all link elements, extract href attributes, and use HTTP libraries (like
HttpURLConnection) to validate status codes.
23. How do you assert values in Selenium?

Answer: Use test frameworks like JUnit/TestNG with assertEquals(), assertTrue(), etc.

24. How do you generate logs in Selenium tests?

Answer: Use Java logging frameworks like Log4j or built-in loggers to print execution details.

25. How do you retry failed tests?

Answer: Implement retry logic in TestNG using IRetryAnalyzer, or configure test reruns in your
CI tool.

26. What is Selenium Grid?

Answer: A tool that lets you run tests across multiple machines, browsers, and OSes in parallel.

27. What’s the role of DesiredCapabilities?

Answer: Used to set browser-specific configurations for WebDriver sessions (mostly replaced by
Options classes in newer versions).

28. What is FluentWait in Selenium?

Answer: A wait that defines the frequency to check conditions and ignores exceptions during the
wait period.

29. How do you handle CAPTCHA in Selenium?

Answer: CAPTCHA is designed to block automation. Workarounds include bypass mechanisms


or asking devs for a test-friendly version.
30. What are the limitations of Selenium?

Answer: Cannot test non-browser apps. No built-in reporting. Limited support for CAPTCHA,
image comparison, and barcode testing. Needs coding knowledge and maintenance

You might also like