Selenium Interview Questions & Answers (Python)
Q: What is Selenium?
A: Selenium is an open-source automation testing tool used to test web applications across
different browsers and platforms.
Q: What are the components of Selenium?
A: Selenium IDE, Selenium WebDriver, Selenium Grid.
Q: What is WebDriver?
A: WebDriver is a Selenium component that provides APIs to interact with browsers
programmatically.
Q: Difference between Selenium and QTP?
A: Selenium is open-source and supports multiple languages; QTP is licensed and supports
limited languages.
Q: What are locators?
A: Locators are used to identify web elements on a webpage.
Q: Types of locators in Selenium?
A: ID, Name, Class Name, Tag Name, Link Text, Partial Link Text, XPath, CSS Selector.
Q: What is XPath?
A: XPath is a language used to locate elements using XML path expressions.
Q: Difference between Absolute and Relative XPath?
A: Absolute XPath starts from root and is not reliable; Relative XPath starts anywhere and is
reliable.
Q: What is CSS Selector?
A: CSS Selector is used to locate elements using CSS patterns.
Q: What is implicit wait?
A: Implicit wait waits for a defined time before throwing exception for element not found.
Q: What is explicit wait?
A: Explicit wait waits for a specific condition to occur before proceeding.
Q: Difference between implicit and explicit wait?
A: Implicit wait is global; Explicit wait is applied to specific elements.
Q: What is fluent wait?
A: Fluent wait defines polling frequency and ignores specific exceptions.
Q: What is StaleElementReferenceException?
A: Occurs when the referenced element is no longer attached to the DOM.
Q: How to handle alerts?
A: Using driver.switch_to.[Link](), dismiss(), send_keys().
Q: How to handle frames?
A: Using driver.switch_to.frame() and switch_to.default_content().
Q: How to handle multiple windows?
A: Using driver.window_handles and switch_to.window().
Q: How to handle dropdowns?
A: Using Select class.
Q: What is ActionChains?
A: Used to perform mouse and keyboard actions.
Q: What is JavaScriptExecutor?
A: Used to execute JavaScript code within the browser.
Q: How to take screenshot?
A: Using driver.save_screenshot().
Q: What is Page Object Model?
A: Design pattern to create object repository for UI elements.
Q: What is TestNG / PyTest?
A: Testing frameworks used to manage and execute test cases.
Q: What is Selenium Grid?
A: Used to run tests in parallel across multiple machines and browsers.
Q: Limitations of Selenium?
A: Cannot test desktop apps, limited reporting, no built-in test management.
Q: What is headless browser?
A: Browser running without UI.
Q: How to upload file in Selenium?
A: By sending file path using send_keys().
Q: Difference between find_element and find_elements?
A: find_element returns single element; find_elements returns list.
Q: What is desired capabilities?
A: Used to configure browser properties.
Q: What is synchronization in Selenium?
A: Handling dynamic elements using waits.