Selenium Interview Questions and Answers

fresher Interview Questions & Answers

Q1. What is Selenium?

Ans: Selenium is a framework for testing web applications automatically.

Q2. What are the components of Selenium?

Ans: Selenium IDE, WebDriver, RC (deprecated), and Grid.

Q3. What is Selenium WebDriver?

Ans: It is a tool for automating web application testing across browsers.

Q4. What is locators in Selenium?

Ans: Locators are used to find elements like id, name, xpath, cssSelector, etc.

Q5. How do you launch a browser?

Ans: By creating a WebDriver instance like new ChromeDriver().

Q6. What is an XPath?

Ans: XPath is a language used to locate elements using XML path.

Q7. What is the difference between assert and verify?

Ans: Assert stops test on failure; verify continues even if test fails.

Q8. What is implicit wait?

Ans: Implicit wait sets a default wait time for element search globally.

Q9. What is explicit wait?

Ans: Explicit wait waits for a certain condition before proceeding.

Q10. What are TestNG annotations?

Ans: They define execution sequence like @Test, @BeforeMethod, etc.

Q11. What is Page Object Model (POM)?

Ans: A design pattern for creating object repositories for web UI elements.

Q12. What is a headless browser?

Ans: A browser without GUI, used for faster testing like HtmlUnitDriver.

Q13. How do you handle alerts?

Ans: Using Alert interface with switchTo().alert().

Q14. How to handle dropdowns?

Ans: Using Select class and its methods like selectByVisibleText().

Q15. What is the use of driver.quit()?

Ans: Closes all browser windows and ends WebDriver session.