Test Overview
This test opens a Chrome browser with specific options set using ChromeOptions. It verifies that the browser starts maximized and navigates to the correct URL.
This test opens a Chrome browser with specific options set using ChromeOptions. It verifies that the browser starts maximized and navigates to the correct URL.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; 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 ChromeOptionsTest { private WebDriver driver; @BeforeEach public void setUp() { ChromeOptions options = new ChromeOptions(); options.addArguments("--start-maximized"); driver = new ChromeDriver(options); } @Test public void testNavigateToExampleDotCom() { driver.get("https://example.com"); String currentUrl = driver.getCurrentUrl(); assertEquals("https://example.com/", currentUrl); } @AfterEach public void tearDown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Create ChromeOptions and add argument '--start-maximized' | ChromeOptions object configured with start maximized argument | - | PASS |
| 2 | Initialize ChromeDriver with ChromeOptions | Chrome browser opens maximized | - | PASS |
| 3 | Navigate to 'https://example.com' | Browser loads the example.com homepage | - | PASS |
| 4 | Get current URL from browser | Current URL is 'https://example.com/' | Assert current URL equals 'https://example.com/' | PASS |
| 5 | Quit the browser | Browser closes | - | PASS |