Test Overview
This test verifies that Selenium WebDriver is correctly configured as a dependency in a Java project using Maven. It checks if the WebDriver can be instantiated and a simple browser action can be performed.
This test verifies that Selenium WebDriver is correctly configured as a dependency in a Java project using Maven. It checks if the WebDriver can be instantiated and a simple browser action can be performed.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; public class SeleniumDependencyTest { private WebDriver driver; @BeforeEach public void setUp() { // Assuming chromedriver executable is in system PATH driver = new ChromeDriver(); } @Test public void testOpenGoogle() { driver.get("https://www.google.com"); String title = driver.getTitle(); assertTrue(title.contains("Google"), "Title should contain 'Google'"); } @AfterEach public void tearDown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and JUnit initializes the test class | JUnit test runner is ready to execute tests | - | PASS |
| 2 | BeforeEach method runs: ChromeDriver instance is created | Chrome browser window opens controlled by WebDriver | ChromeDriver object is not null | PASS |
| 3 | Test method runs: WebDriver navigates to https://www.google.com | Browser displays Google homepage | Page title contains 'Google' | PASS |
| 4 | AfterEach method runs: WebDriver quits and browser closes | Browser window is closed, WebDriver session ends | - | PASS |
| 5 | Test finishes and JUnit reports results | Test report shows test passed | All assertions passed | PASS |