use of com.codeborne.selenide.ex.ElementNotFound in project syndesis-qe by syndesisio.
the class CommonSteps method loginToGoogleIfNeeded.
private void loginToGoogleIfNeeded(String s) {
// if the browser has previously logged into google account syndesis will
// immediately move to next screen and will have "Successfully%20authorized%20Syndesis's%20access" in the URL
log.info("Current url: {}", WebDriverRunner.getWebDriver().getCurrentUrl().toLowerCase());
if (isStringInUrl("Successfully%20authorized%20Syndesis's%20access", 5) || $(Alert.SUCCESS.getBy()).is(visible)) {
log.info("User is already logged");
return;
}
waitForCallbackRedirect("google");
Account account = AccountsDirectory.getInstance().get(s);
// change language if needs
if ($(ByUtils.customAttribute("data-value", "en")).has(Condition.attribute("tabindex", "-1"))) {
$(By.id("lang-chooser")).click();
TestUtils.sleepIgnoreInterrupt(2000);
$(By.id("lang-chooser")).$$(ByUtils.customAttribute("data-value", "en")).filter(Condition.visible).get(0).click();
TestUtils.sleepIgnoreInterrupt(2000);
}
// test if multi accounts table is shown ( https://accounts.google.com/accountchooser )
SelenideElement loginView = $(By.id("initialView"));
if (loginView.text().contains("Choose an account")) {
log.info("More Google accounts are available. Choosing the correct one:" + account.getProperty("email"));
try {
loginView.$(ByUtils.customAttribute("data-email", account.getProperty("email"))).should(Condition.exist).click();
} catch (ElementNotFound ex) {
log.warn("That account is not in the Google multi-accounts table. It needs to fill in the credentials.");
// use another account button
loginView.$$(ByUtils.hasEqualText("div", "Use another account")).filter(visible).last().click();
fillAndValidateGoogleAccount(account);
}
} else {
fillAndValidateGoogleAccount(account);
}
TestUtils.sleepIgnoreInterrupt(5000L);
}
Aggregations