Careeroza
First Script
Open ShopEase and Print the Title
package com.shopease.tests;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstTest {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver(); // 1. start Chrome
driver.get("https://shopease.example.com"); // 2. open the site
System.out.println("Title: " + driver.getTitle()); // 3. read the title
driver.quit(); // 4. close the browser
}
}What Happens
Example
Right-click the file → Run "FirstTest.main()". Chrome opens with the banner "Chrome is being controlled by automated test software", loads the page, then closes. The console shows:
Run FirstTest.main()Example output
Title: ShopEase - Online Shopping for Electronics, Fashion and More Process finished with exit code 0
Note: Always end with driver.quit(). Otherwise Chrome and chromedriver processes stay open in the background and eat memory.
Turn It Into a Check
String title = driver.getTitle();
if (title.contains("ShopEase")) {
System.out.println("PASS: home page opened");
} else {
System.out.println("FAIL: title was " + title);
}Exercise: Change the script to open https://shopease.example.com/login and print both the title and the current URL.
Show answer
driver.get("https://shopease.example.com/login");
System.out.println("Title: " + driver.getTitle());
System.out.println("URL: " + driver.getCurrentUrl());