Last active
September 26, 2016 09:27
-
-
Save sahajamit/f3f7aab160ca7cc54b9262e460d89256 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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