mercredi 21 janvier 2015

Testing logout with selenium

Hi im new to selenium and i have to test if user can logout from page, heres my method for testing it, but unfortunately it doesnt never gets to the page, i think im missing something in the method :



public boolean logOut() {
WebDriver driver = getDriver();
//driver.get(BASE_URL);
driver.get("http://ift.tt/1yrHtPf");
elementById("log_out_link").click();

if(!driver.getCurrentUrl().equals("http://ift.tt/1yrHtPl"))
{
return false;
}

return true;
}


Heres the test if user returns to the main page it should return true so the test will pass but it always returns false:



@Test
public void logOutSuccess() {
LoginPage loginPage = LoginPage.goTo();
loginPage.logInWith(USERNAME, CORRECT_PASSWORD);
System.out.println(driver.getPageSource());
assertThat(loginPage.logOut(), is(true));
}

Aucun commentaire:

Enregistrer un commentaire