* @throws Exception
*/
void testAutoLogin(String loginUrl, String loginLoadedLinkText, String logoutLinkText) throws Exception
{
driver.get(loginUrl);
WebDriverWait wait = new WebDriverWait(driver, getTimeout());
// wait for Login, but we are not gonna click it testing AUTOACCEPT works.
// TODO fix assumption that all sites have a direct Login page, but not all do.
if (loginLoadedLinkText != null && !loginLoadedLinkText.equals(""))
{
wait.until(ExpectedConditions.elementToBeClickable(By.linkText(loginLoadedLinkText)));
}
else
{
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html")));
}
screenshot(); // of given loginUrl
// various in page login pop-ups are detected by MP and can be submitted without clicking the link
// that makes them visible.
// TODO handle the other cases
if (loginLoadedLinkText != null && !loginLoadedLinkText.equals(""))
{
wait.until(ExpectedConditions.elementToBeClickable(By.linkText(loginLoadedLinkText)));
}
Thread.sleep(1000);
if (logoutLinkText != null && !logoutLinkText.equals(""))
{
WebElement logout = wait.until(ExpectedConditions.elementToBeClickable(By.linkText(logoutLinkText)));
// logout.click(); // clicking log out is nearly useless, MP will log back in immediately with AUTOACCEPT
}
else
{
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html")));
}
screenshot();
}