Test case TC-001: open the app, verify the login page loads.
Today that test case becomes code that opens a real Chrome window by itself. This is the moment the career change gets real.
Everything so far — Java, the terminal, locators — converges here. Selenium's WebDriver is an object (OOP lesson!) whose methods drive a real browser. Modern Selenium handles the browser driver automatically via Selenium Manager, so there's nothing to download: if Chrome is installed, this just runs.
Add this class to your starter project at src/test/java/FirstSeleniumTest.java:
import org.junit.jupiter.api.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import static org.junit.jupiter.api.Assertions.assertEquals; public class FirstSeleniumTest { @Test void loginPageLoads() { WebDriver driver = new ChromeDriver(); // opens a real Chrome window driver.get("https://www.saucedemo.com"); // navigate String title = driver.getTitle(); // read state from the browser System.out.println("Page title is: " + title); assertEquals("Swag Labs", title); // the assertion — expected vs actual driver.quit(); // ALWAYS close the browser } }
Run it with the green arrow, or from PowerShell:
mvn test -Dtest=FirstSeleniumTest
[INFO] Running FirstSeleniumTest Page title is: Swag Labs [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] BUILD SUCCESS
A Chrome window flashed open, loaded the page, and closed. That flash was your code driving a browser. Read the test again top to bottom — it's your manual TC-001, line for line: navigate, observe, compare to expected.
new ChromeDriver() starts a browser session; driver.quit() ends it. Forget quit() and you leak browser processes — run a suite of 50 tests that way and your machine crawls. (Suite 05's @AfterEach will guarantee it runs even when tests fail.)
SessionNotCreatedException mentioning versions means Chrome just auto-updated; simply re-run.Fix: Chrome isn't installed, or a corporate proxy blocked Selenium Manager's one-time driver download. Install Chrome; try once on a personal network — the driver caches afterwards. A version-mismatch message usually just means Chrome auto-updated: re-run.
Fix: Either the import is missing (org.openqa.selenium.chrome.ChromeDriver) or Maven hasn't finished downloading dependencies — check the bottom-right progress bar, then Maven → Reload project.
Fix: That flash is success: your test opened Chrome, asserted, and quit. Add a breakpoint or a temporary wait if you want to watch it work.
"Wrong Title", run, and read the failure: expected: <Wrong Title> but was: <Swag Labs>. That message format will be your daily companion. Fix it.googleLoads() that opens https://www.google.com and asserts the title equals "Google".driver.getCurrentUrl() too — notice saucedemo redirects to a trailing slash. URL and title are your two cheapest checkpoints.