1. What is Selenium?
Selenium is an open-source automation testing tool used for testing web applications. It supports multiple browsers like Chrome, Firefox, and Edge, and allows testers to write scripts in various programming languages such as Java, Python, and C#. Selenium only supports web applications, not desktop or mobile apps.
2. What are the components of Selenium?
Selenium has four main components:
1. Selenium IDE – Record and playback tool.
2. Selenium RC – (deprecated) allowed execution of test scripts.
3. Selenium WebDriver – Modern automation tool that directly interacts with
browsers.
4. Selenium Grid – Used to run tests in parallel across multiple browsers and
machines.
3. What are the advantages of using Selenium?
- Open-source and free to use.
- Supports multiple browsers and operating systems.
- Supports different programming languages.
- Can be integrated with tools like TestNG, JUnit, Maven, Jenkins, etc. for
CI/CD.
- Large community support.
4. What are the limitations of Selenium?
- It only supports web applications, not desktop or mobile
apps.
- No built-in reporting feature (needs integration with other tools).
- Does not handle captcha, barcode, OTP, or image-based testing directly.
- Requires good programming knowledge.
5. What is Selenium WebDriver?
Selenium WebDriver is a tool used to automate web application testing. It directly communicates with the browser without requiring a server. It provides APIs to interact with web elements like buttons, input fields, and checkboxes.
6. What are locators in Selenium?
Locators are ways to identify elements on a web page so that
Selenium can interact with them. Common locators are:
- id
- name
- className
- tagName
- linkText
- partialLinkText
- cssSelector
- xpath
7. What is the difference between findElement() and findElements()?
- findElement(): Returns the first matching web element. If
no element is found, it throws NoSuchElementException.
- findElements(): Returns a list of matching web elements. If no elements are
found, it returns an empty list.
8. How do you handle dropdowns in Selenium?
We use the Select class to handle dropdowns in Selenium.
Example in Java:
Select select = new Select(driver.findElement(By.id("dropdown")));
select.selectByVisibleText("Option1");
select.selectByIndex(2);
select.selectByValue("val");
9. How do you handle alerts in Selenium?
Alerts are handled using the Alert interface. Example:
Alert alert = driver.switchTo().alert();
alert.accept(); // Clicks OK
alert.dismiss(); // Clicks Cancel
alert.getText(); // Reads alert text
alert.sendKeys("input"); // Sends text to alert
10. What are waits in Selenium?
Waits are used to handle synchronization issues in Selenium:
- Implicit Wait: Sets a default wait time for the entire script.
- Explicit Wait: Waits for a specific condition to occur before proceeding.
- Fluent Wait: Similar to explicit wait but also defines polling frequency and
can ignore exceptions.
Stay tuned for more questions.
0 Comments