Last active
May 7, 2020 16:15
-
-
Save batmi02/00db15add77cbf0802efffe3511de40e to your computer and use it in GitHub Desktop.
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 loginClassicTest() { | |
//Open browser | |
//This is our first instruction, directing us to the login page. One line of code. | |
driver.get("http://localhost:8000/loginBefore.html") | |
//Click on the Login button | |
//This is our second instruction, directing action by finding the id 'log-in' and clicking. One line of code. | |
driver.findElement(By.id("log-in")).click(); | |
//Assertions Section | |
//What follows are assertions of individual elements on the page | |
//3 checks for the login box (field exists, placeholder exists, correct text) | |
//3 checks for the password box (field exists, placeholder exists, correct text) | |
//2 checks for the sign in button (exists, text) | |
//1 check for the Remember Me checkbox existence | |
//1 check for the Remember Me text | |
//1 check for the Twitter button | |
//1 check for the Facebook button | |
//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 username", 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 SignIn button 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("//form//a[1]//img[2]")) instanceof WebElement); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment