Test Overview
This test sets up the Chrome WebDriver, opens the Chrome browser, and verifies that the browser window is opened successfully.
This test sets up the Chrome WebDriver, opens the Chrome browser, and verifies that the browser window is opened successfully.
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.assertNotNull; public class ChromeDriverSetupTest { private WebDriver driver; @BeforeEach public void setUp() { // Set the path to chromedriver executable if needed // System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver"); driver = new ChromeDriver(); } @Test public void testChromeDriverSetup() { driver.get("about:blank"); assertNotNull(driver.getWindowHandle(), "Browser window should be opened"); } @AfterEach public void tearDown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Initialize ChromeDriver instance | Chrome browser process starts but no page loaded yet | - | PASS |
| 2 | Navigate to about:blank page | Chrome browser opens a blank page | - | PASS |
| 3 | Get window handle to verify browser window is opened | Browser window handle is retrieved | Assert that window handle is not null | PASS |
| 4 | Close the browser and quit driver | Browser window closes and driver quits | - | PASS |