use of org.openqa.selenium.NoSuchElementException in project uaa by cloudfoundry.
the class SamlLoginWithLocalIdpIT method performLogin.
public void performLogin(String idpZoneId, String idpZoneUserEmail, String idpZoneUrl, IdentityZone spZone, String spZoneUrl, SamlIdentityProviderDefinition samlIdentityProviderDefinition) {
webDriver.get(baseUrl + "/logout.do");
webDriver.get(spZoneUrl + "/logout.do");
webDriver.get(idpZoneUrl + "/logout.do");
webDriver.get(spZoneUrl + "/");
assertEquals(spZone.getName(), webDriver.getTitle());
Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(beforeLogin);
assertNotNull(beforeLogin.getValue());
List<WebElement> elements = webDriver.findElements(By.xpath("//a[text()='" + samlIdentityProviderDefinition.getLinkText() + "']"));
assertNotNull(elements);
assertEquals(1, elements.size());
WebElement element = elements.get(0);
assertNotNull(element);
element.click();
try {
webDriver.findElement(By.xpath("//h1[contains(text(), 'Welcome to The Twiglet Zone[" + idpZoneId + "]!')]"));
webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys(idpZoneUserEmail);
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(afterLogin);
assertNotNull(afterLogin.getValue());
assertNotEquals(beforeLogin.getValue(), afterLogin.getValue());
} catch (Exception e) {
assertTrue("Http-Artifact binding is not supported", e instanceof NoSuchElementException);
}
}
use of org.openqa.selenium.NoSuchElementException in project uaa by cloudfoundry.
the class LdapLoginIT method saveAlertErrorMessage.
private void saveAlertErrorMessage() {
try {
WebElement element = webDriver.findElement(By.className("alert-error"));
alertError = Optional.of(element.getText());
} catch (NoSuchElementException e) {
// do nothing
}
}
use of org.openqa.selenium.NoSuchElementException in project selenium_tests by sergueik.
the class YandexTest method doLogin.
private String doLogin() {
// I enter the username
// NOTE: elements with class names ending with "Label" e.g.
// "passport-Input-Label"
// would not accept input
WebElement element = driver.findElement(By.xpath("//form//input[@name='login']"));
System.err.println("Form element containing login: " + element.findElement(By.xpath("..")).findElement(By.xpath("..")).getAttribute("outerHTML"));
highlight(element);
element.clear();
element.sendKeys(username);
element = driver.findElement(By.cssSelector("input[name='passwd']"));
highlight(element);
element.clear();
element.sendKeys(password);
// TODO: Assert that input gets added to the background form
System.err.println("Password: " + element.getAttribute("value"));
// Evaluate the landing page URL
// element = driver
// .findElement(By.cssSelector("form.new-auth-form input[name='passwd']"));
element = driver.findElement(By.cssSelector("form button[type='submit']"));
highlight(element);
element = driver.findElement(By.cssSelector("form a.nb-button"));
String login_href = element.getAttribute("href");
System.err.println("Login href: " + login_href);
String matcherExpression = String.format("%s/auth\\?(?:.*)&retpath=(.+)&(?:.*)", loginURL);
System.err.println("Matcher: " + matcherExpression);
Pattern pattern = Pattern.compile(matcherExpression);
Matcher matcher = pattern.matcher(login_href);
String retpath = null;
if (matcher.find()) {
try {
retpath = java.net.URLDecoder.decode(matcher.group(1).toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
// ignore
}
}
System.err.println("Login retpath: " + retpath);
// And I click the login button
element = driver.findElement(By.cssSelector("form button[type='submit']"));
highlight(element);
// String currentUrl = driver.getCurrentUrl();
element.click();
// wait until browser is away from the login page
System.err.println("Waiting to get away from " + loginURL);
try {
wait.until(ExpectedConditions.not(ExpectedConditions.urlContains(loginURL)));
} catch (TimeoutException tex) {
try {
element = driver.findElement(By.cssSelector("div.layout-inner div.js-messages div.error-msg"));
String errorMessageTranslated = Translit.toAscii(element.getText());
verificationErrors.append("Getting error message " + errorMessageTranslated);
System.err.println("Getting error message " + errorMessageTranslated);
} catch (NoSuchElementException elex) {
// ignore
}
verificationErrors.append(tex.toString());
}
System.err.println("Waiting for " + retpath);
// wait until browser is on the landing page
wait.until(ExpectedConditions.urlContains(retpath));
// System.out.println("Page url: " + driver.getCurrentUrl());
try {
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.mail-App-Header div.mail-User")));
} catch (TimeoutException | UnreachableBrowserException e) {
verificationErrors.append(e.toString());
}
return retpath;
}
use of org.openqa.selenium.NoSuchElementException in project selenium_tests by sergueik.
the class GeoPlacesDropdownTest method testDropdownSelect.
@Test(enabled = true)
public void testDropdownSelect() {
// Arrange
// work with the address input
element = iframeDriver.findElement(By.id("pac-input"));
assertThat(element, notNullValue());
// Act
element.sendKeys(searchText);
sleep(1000);
// scroll few items down through the search results menu
actions = new Actions(iframeDriver);
for (int cnt = 0; cnt != 10; cnt++) {
actions.sendKeys(Keys.ARROW_DOWN).perform();
sleep(500);
}
// the dynamic div is visible in Firefox, not in Chrome or Vivaldi -
// Shadow DOM present ?
/*
<div class="pac-container pac-logo hdpi" style="width: 398px; position: absolute; left: 17px; top: 39px; display: none;">
<div class="pac-item">
<span class="pac-icon pac-icon-marker"/>
<span class="pac-item-query">
<span class="pac-matched">Miami Airport</span>
</span>
<span><span class="pac-matched">Mia</span>mi, FL, USA</span>
</div>
<div class="pac-item">
<span class="pac-icon pac-icon-marker"/>
<span class="pac-item-query">
<span class="pac-matched">Miami International Airport (MIA)</span>
</span>
<span>Northwest 42nd Avenue, Miami, <span class="pac-matched">Mia</span>mi-Dade, FL, USA</span>
</div>
</div>
*/
// Assert
elements = iframeDriver.findElements(By.className("pac-item"));
assertThat(elements, notNullValue());
iteratorElements = elements.iterator();
cnt = 0;
while (iteratorElements.hasNext()) {
cnt++;
element = iteratorElements.next();
// System.err.println(element.getAttribute("outerHTML"));
text = null;
try {
text = element.getText();
assertThat(text, notNullValue());
System.err.println(String.format("geocode search result %2d: %s", cnt, text));
} catch (NoSuchElementException e) {
System.err.println("Exception (ignored): " + e.getMessage());
}
}
// count results added to the page
assertThat(cnt, not(greaterThan(maxItems)));
}
use of org.openqa.selenium.NoSuchElementException in project selenium_tests by sergueik.
the class MultilineLocalizedPageSearchTest method failedReciprocalMultilineTextSearchTest.
@Test(enabled = false)
public void failedReciprocalMultilineTextSearchTest() {
List<WebElement> elements = driver.findElements(By.cssSelector(elementCssSelector));
String elementText = elements.get(0).getText();
try {
WebElement element = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath(String.format(complexXPathTemplate, elementText)))));
if (element != null) {
highlight(element);
}
} catch (NoSuchElementException e) {
System.err.println("Exception (ignored): " + e.toString());
}
}
Aggregations