Skip to content

Instantly share code, notes, and snippets.

@borodicht
Created January 12, 2026 09:36
Show Gist options
  • Select an option

  • Save borodicht/3b600725853c57e637ab270a6ead2025 to your computer and use it in GitHub Desktop.

Select an option

Save borodicht/3b600725853c57e637ab270a6ead2025 to your computer and use it in GitHub Desktop.
package org.demo.ui;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class LoginPage {
private final WebDriver driver;
public LoginPage(WebDriver driver) {
this.driver = driver;
}
public void open() {
driver.get("https://www.saucedemo.com/");
}
public void login(String user, String pass) {
driver.findElement(By.id("user-name")).sendKeys(user);
driver.findElement(By.id("password")).sendKeys(pass);
driver.findElement(By.id("login-button")).click();
}
public boolean isErrorVisible() {
return !driver.findElements(By.cssSelector("[data-test='error']")).isEmpty();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment