Last active
October 7, 2019 21:20
-
-
Save alsargent/e53fa91f080d9e485ed58b940e11d585 to your computer and use it in GitHub Desktop.
Functional testing without Visual AI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void loginLegacyTest() { | |
//Open browser | |
driver.get("http://localhost:8000/loginBefore.html"); | |
//Click on the Login button | |
driver.findElement(By.id("log-in")).click(); | |
//Assert the error text | |
assertEquals("Please enter username and password",driver.findElement(By.id("alert")).getText()); | |
//Assert if username field exists | |
assertTrue((driver.findElement(By.id("username")) instanceof WebElement)); | |
//Assert username placeholder text | |
assertEquals("Enter your username",driver.findElement(By.id("username")).getAttribute("placeholder")); | |
//Assert username label exists | |
assertEquals("Username", driver.findElement(By.xpath("(//label)[1]")).getText()); | |
//Assert if password field exists | |
assertTrue((driver.findElement(By.id("password")) instanceof WebElement)); | |
//Assert password placeholder text | |
assertEquals("Enter your password",driver.findElement(By.id("password")).getAttribute("placeholder")); | |
//Assert password label exists | |
assertEquals("Password", driver.findElement(By.xpath("(//label)[2]")).getText()); | |
//Assert if SignIn button field exists | |
assertTrue((driver.findElement(By.id("log-in")) instanceof WebElement)); | |
//Assert if SignIn buttons label is "Sign In" | |
assertEquals("Sign in", driver.findElement(By.id("log-in")).getText()); | |
//Assert Remember Me checkbox exists | |
assertTrue((driver.findElement(By.xpath("//input[@class='form-check-input']")) instanceof WebElement)); | |
//Assert if Remember Me text exists | |
assertEquals("Remember Me", driver.findElement(By.xpath("(//label)[3]")).getText()); | |
//Assert if Twitter button exists | |
assertTrue(driver.findElement(By.xpath("//form//a[1]//img[1]")) instanceof WebElement); | |
//Assert if Facebook button exists | |
assertTrue(driver.findElement(By.xpath("//a[2]//img[1]")) instanceof WebElement); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment