Test Overview
This test checks if the Java environment is correctly set up for Selenium testing. It verifies that the JDK is installed, the IDE can compile and run a simple Selenium test, and the browser driver is accessible.
This test checks if the Java environment is correctly set up for Selenium testing. It verifies that the JDK is installed, the IDE can compile and run a simple Selenium test, and the browser driver is accessible.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class EnvironmentSetupTest { public static void main(String[] args) { // Set path to chromedriver executable System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe"); // Initialize ChromeDriver WebDriver driver = new ChromeDriver(); // Open a simple website driver.get("https://www.example.com"); // Check page title String title = driver.getTitle(); if (title.equals("Example Domain")) { System.out.println("Test Passed: Correct page loaded."); } else { System.out.println("Test Failed: Incorrect page title."); } // Close browser driver.quit(); } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Start IDE and open Java project with Selenium dependencies | IDE is open with the test code loaded and ready to run | - | PASS |
| 2 | Compile the Java test code | Code compiles without errors | No compilation errors | PASS |
| 3 | Run the test main method | Browser window opens and navigates to https://www.example.com | Browser opens and loads the page | PASS |
| 4 | Retrieve the page title from the browser | Page title is fetched as 'Example Domain' | Page title equals 'Example Domain' | PASS |
| 5 | Print test result message to console | Console shows 'Test Passed: Correct page loaded.' | Output message confirms correct page loaded | PASS |
| 6 | Close the browser and end the test | Browser window closes | - | PASS |