Test Overview
This test verifies that a Maven project is created successfully and that Selenium WebDriver can open a browser and navigate to a webpage.
This test verifies that a Maven project is created successfully and that Selenium WebDriver can open a browser and navigate to a webpage.
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.assertEquals; public class MavenProjectTest { 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 testOpenGoogle() { driver.get("https://www.google.com"); String title = driver.getTitle(); assertEquals("Google", title, "Page title should be Google"); } @AfterEach public void tearDown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | JUnit test runner initializes the test class | - | PASS |
| 2 | BeforeEach method runs: ChromeDriver instance is created | Chrome browser window opens | - | PASS |
| 3 | Test method runs: driver navigates to https://www.google.com | Browser displays Google homepage | Check page title equals 'Google' | PASS |
| 4 | Assertion checks page title | Page title is 'Google' | assertEquals("Google", title) | PASS |
| 5 | AfterEach method runs: driver quits | Browser window closes | - | PASS |