In Selenium Java testing, modular frameworks break tests into reusable parts. Why does this help scale testing?
Think about how reusing pieces saves time and effort when tests grow.
Modular design breaks tests into small reusable parts. This means new tests can be built quickly by combining modules, making it easier to add many tests as the project grows.
Consider this simplified Selenium Java test framework code snippet. What will be printed when running the test?
public class TestFramework { public static void runTest() { System.out.println("Setup browser"); System.out.println("Execute test steps"); System.out.println("Cleanup browser"); } public static void main(String[] args) { runTest(); } }
Look at the order of the print statements inside runTest method.
The method prints messages in the order: setup, execute, cleanup. The main method calls runTest once, so output matches option A.
You want to check if the page title is exactly "Home Page" after loading. Which assertion is correct?
String actualTitle = driver.getTitle();
Exact match is required, not just containment or null check.
assertEquals compares expected and actual values exactly. Other options check partial match, non-null, or false condition, which do not verify exact title.
Why does this Selenium Java code throw NoSuchElementException?
WebElement button = driver.findElement(By.id("submitBtn"));
button.click();Check if the element exists and is visible before clicking.
NoSuchElementException means Selenium cannot find the element. Usually this happens if the element is missing or page is not fully loaded.
To run many Selenium tests at the same time without interference, which design feature is most important?
Think about how tests running at the same time avoid affecting each other.
Parallel tests need separate WebDriver instances per thread to avoid conflicts. Sharing one instance causes errors. Static fields cause shared state issues.