Test Overview
This test verifies that the Selenium WebDriver correctly loads configuration settings from a properties file and uses them to open a specified URL and check the page title.
This test verifies that the Selenium WebDriver correctly loads configuration settings from a properties file and uses them to open a specified URL and check the page title.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.junit.jupiter.api.*; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class ConfigManagementTest { static WebDriver driver; static Properties config = new Properties(); @BeforeAll public static void setup() throws IOException { FileInputStream fis = new FileInputStream("config.properties"); config.load(fis); System.setProperty("webdriver.chrome.driver", config.getProperty("chrome.driver.path")); driver = new ChromeDriver(); } @Test public void testOpenUrlAndCheckTitle() { String url = config.getProperty("app.url"); String expectedTitle = config.getProperty("app.title"); driver.get(url); Assertions.assertEquals(expectedTitle, driver.getTitle()); } @AfterAll public static void teardown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Load configuration from 'config.properties' file | Properties object contains keys: 'chrome.driver.path', 'app.url', 'app.title' | Check that properties file loaded without IOException | PASS |
| 2 | Set system property 'webdriver.chrome.driver' with path from config | System property set for ChromeDriver executable path | - | PASS |
| 3 | Initialize ChromeDriver instance | Chrome browser window opens | Driver instance is not null | PASS |
| 4 | Navigate to URL from configuration | Browser loads the page at configured URL | Page title is retrievable | PASS |
| 5 | Assert that page title matches expected title from config | Browser shows the loaded page | assertEquals(expectedTitle, actualTitle) | PASS |
| 6 | Close browser and quit driver | Browser window closes, driver quits | - | PASS |