Skip to content

Instantly share code, notes, and snippets.

@sahajamit
Last active September 26, 2016 09:27
Show Gist options
  • Save sahajamit/f3f7aab160ca7cc54b9262e460d89256 to your computer and use it in GitHub Desktop.
Save sahajamit/f3f7aab160ca7cc54b9262e460d89256 to your computer and use it in GitHub Desktop.
@And("^we login to the UI with correct credentials$")
public void weLoginToTheRiskViewUIWithCorrect() throws Throwable {
homePage = loginPage.doLogin(context.get("USER").toString(), context.get("PASSWORD").toString(), false);
}
@And("^we login to the UI with incorrect credentials$")
public void weLoginToTheRiskViewUIWithIncorrectCredentials() throws Throwable {
loginPage = loginPage.doLogin(context.get("USER").toString(), context.get("INCORRECT_PASSWORD").toString(), true);
}
public <T extends basePage> T doLogin(String username, String password,boolean isFailedLogin) {
if(password.equals("")){
throw new IllegalStateException("Password cannot be Blank");
}
userNameField.sendKeys(username);
passwordField.sendKeys(password);
loginButton.click();
if(!isFailedLogin){
return (T)new HomePage().openPage(HomePage.class);
}else{
return (T)new LoginPage().openPage(LoginPage.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment