Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample automation script to log in then log out of http://flipkart.com. Using the https://github.com/ddavison/getting-started-with-selenium framework.
@Config(url="http://flipkart.com", browser=Browser.FIREFOX)
public class TestFlipKart extends AutomationTest {
@Test
public void testLoginLogout() {
String username = "<username>";
String password = "<password>";
click(By.cssSelector("a[href*='/login']"))
.setText(By.cssSelector("input[name='email']"), username)
.setText(By.cssSelector("input[name='password']"), password)
.click(By.cssSelector("input[type='submit'][value='Login']"))
.validatePresent(By.cssSelector("li.greeting-link > a"))
.hoverOver(By.cssSelector("li.greeting-link > a"))
.click(By.cssSelector("ul.account-dropdown a[href*='/logout']"))
// should be logged out now.
.validatePresent(By.cssSelector("a[href*='/login']"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment