Careeroza
Title URL and Page Source
Reading Page Information
driver.get("https://shopease.example.com/login");
System.out.println(driver.getTitle()); // text in <title>
System.out.println(driver.getCurrentUrl()); // URL after any redirects
String html = driver.getPageSource(); // full HTML of the current page
System.out.println(html.contains("login-btn"));Example
Output:
Run LoginPageInfo.main()Example output
Login - ShopEase https://shopease.example.com/login?returnUrl=%2F true
Checking a Redirect
Example
After login ShopEase redirects to /account. The check itself is plain string logic:
public class Main {
public static void main(String[] args) {
String[] urlsAfterLogin = {
"https://shopease.example.com/account",
"https://shopease.example.com/login?error=1"
};
for (String url : urlsAfterLogin) {
boolean ok = url.startsWith("https://") && url.endsWith("/account");
System.out.println(url + " -> " + (ok ? "logged in" : "still on login page"));
}
}
}Output
https://shopease.example.com/account -> logged in https://shopease.example.com/login?error=1 -> still on login page
Tip: Prefer checking the URL or an element over getPageSource(). Page source is large and changes often.