import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class SafewayTest { @Test public void runSafewayTest() throws InterruptedException { WebDriver driver = new ChromeDriver(); //1.get the url driver.get("https://www.safeway.com/"); Thread.sleep(500); //2.Find the "Sign In / Up" link and click it WebElement signInUpLink = driver.findElement(By.xpath("//span[@class='button__item menu-nav__profile-button-sign-in-up d-none d-lg-inline-block dst-sign-in-up']")); signInUpLink.click(); Thread.sleep(1000); //3.Find the "Sign In" link from dropdown and click it WebElement signInLink = driver.findElement((By.id("sign-in-modal-link"))); signInLink.click(); Thread.sleep(1200); //4.Find and click the "Sign In" button WebElement signInButton = driver.findElement((By.id("btnSignIn"))); signInButton.click(); Thread.sleep(1000); //5.Find email error message and verify that it is correct WebElement emailErrorMessage = driver.findElement((By.id("errorMsgEmail"))); boolean isEmailErrorMessageCorrect = emailErrorMessage.getText().equals("Please enter your email address."); Assert.assertTrue("The email error message is incorrect.", isEmailErrorMessageCorrect); //5.Find password error message and verify that it is correct WebElement passwordErrorMessage = driver.findElement((By.id("errorMsgPwd"))); boolean isPasswordErrorMessageCorrect = passwordErrorMessage.getText().equals("Please enter a password."); Assert.assertTrue("The password error message is incorrect.", isPasswordErrorMessageCorrect); //5.Close the browser driver.quit(); } }