Q1. What is Automation Testing?
👉 Automation testing is the process of using tools/scripts to execute test cases automatically, compare actual vs. expected results, and generate reports — without manual intervention.
Q2. Why do we need automation testing?
✅ Faster test execution
✅ Reusability of test scripts
✅ Increased coverage
✅ Reduces human error
✅ Supports CI/CD pipelines
Q3. Which test cases should be automated?
Repetitive test cases
Regression test cases
High-risk or critical business flows
Test cases that are time-consuming manually
Q4. What are challenges in automation?
Handling dynamic elements
Synchronization issues
Test data management
Browser compatibility
Maintenance of scripts
---
💻 2. Selenium WebDriver
Q1. What are locators in Selenium?
Locators help find elements on a web page.
➡️ Types:
id, name, className, tagName, linkText, partialLinkText, xpath, cssSelector
Q2. Difference between findElement() and findElements()?
findElement() → returns single WebElement; throws exception if not found.
findElements() → returns list of WebElements; returns empty list if not found.
Q3. How do you handle dropdowns in Selenium?
Use the Select class.
Select select = new Select(driver.findElement(By.id("country")));
select.selectByVisibleText("India");
Q4. What are waits in Selenium?
Implicit Wait: waits globally for all elements.
Explicit Wait: waits for a specific condition.
Fluent Wait: defines polling interval + exceptions.
Q5. How do you handle multiple windows?
String parent = driver.getWindowHandle();
Set<String> windows = driver.getWindowHandles();
for(String win : windows) {
if(!win.equals(parent)) {
driver.switchTo().window(win);
}
}
Q6. How to take screenshot in Selenium?
File src = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(src, new File("screenshot.png"));
---
0