Test Overview
This test opens Firefox browser with customized options using FirefoxOptions. It verifies the browser starts with the specified options and navigates to the correct URL.
This test opens Firefox browser with customized options using FirefoxOptions. It verifies the browser starts with the specified options and navigates to the correct URL.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; 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 FirefoxOptionsTest { private WebDriver driver; @BeforeEach public void setUp() { FirefoxOptions options = new FirefoxOptions(); options.addArguments("-private"); // Start Firefox in private mode options.setHeadless(true); // Run in headless mode driver = new FirefoxDriver(options); } @Test public void testNavigateToExample() { driver.get("https://example.com"); String title = driver.getTitle(); assertEquals("Example Domain", title); } @AfterEach public void tearDown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Create FirefoxOptions and add '--private-window' argument and set headless mode | FirefoxOptions object configured with private mode and headless true | - | PASS |
| 2 | Initialize FirefoxDriver with configured FirefoxOptions | Firefox browser starts in headless private mode | - | PASS |
| 3 | Navigate to 'https://example.com' | Browser loads the Example Domain page | - | PASS |
| 4 | Get page title and assert it equals 'Example Domain' | Page title is 'Example Domain' | assertEquals("Example Domain", title) | PASS |
| 5 | Quit the browser and clean up | Browser closed, WebDriver session ended | - | PASS |