Test Overview
This test reads a URL from a properties file and verifies that the browser navigates to the correct page. It checks the page title to confirm successful navigation.
This test reads a URL from a properties file and verifies that the browser navigates to the correct page. It checks the page title to confirm successful navigation.
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 ConfigPropertiesTest { static WebDriver driver; static Properties props = new Properties(); @BeforeAll public static void setup() throws IOException { FileInputStream fis = new FileInputStream("config.properties"); props.load(fis); System.setProperty("webdriver.chrome.driver", "path/to/chromedriver"); driver = new ChromeDriver(); } @Test public void testNavigateToUrlFromProperties() { String url = props.getProperty("url"); driver.get(url); String title = driver.getTitle(); Assertions.assertEquals("Example Domain", title); } @AfterAll public static void teardown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Load properties file 'config.properties' from file system | Properties object contains key 'url' with value 'https://example.com' | - | PASS |
| 2 | Set system property for ChromeDriver and launch Chrome browser | Chrome browser window opens, ready for commands | - | PASS |
| 3 | Navigate browser to URL read from properties file | Browser loads 'https://example.com' page | - | PASS |
| 4 | Get page title from browser | Page title is 'Example Domain' | Assert page title equals 'Example Domain' | PASS |
| 5 | Close browser and quit WebDriver | Browser window closes, WebDriver session ends | - | PASS |