use of org.openqa.selenium.support.ui.ExpectedCondition in project chrome_page_performance_sqlite_java by sergueik.
the class ChromePagePerformanceUtilTest method testnavigateBaseURL.
// @Ignore
@Test
public void testnavigateBaseURL() {
System.err.println("base URL loading test");
try {
driver.get(baseURL);
// Wait for page url to update
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.pollingEvery(500, TimeUnit.MILLISECONDS);
ExpectedCondition<Boolean> urlChange = driver -> driver.getCurrentUrl().matches(String.format("^%s.*", baseURL));
wait.until(urlChange);
System.err.println("Current URL: " + driver.getCurrentUrl());
} catch (TimeoutException e) {
}
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project ats-framework by Axway.
the class AbstractRealBrowserDriver method waitForPageLoaded.
public void waitForPageLoaded(WebDriver driver, int timeoutInSeconds) {
/*InternetExplorer is unable to wait for document's readyState to be complete.*/
if (this instanceof com.axway.ats.uiengine.InternetExplorerDriver) {
return;
}
ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return "complete".equals(((JavascriptExecutor) driver).executeScript("return document.readyState"));
}
};
Wait<WebDriver> wait = new WebDriverWait(driver, timeoutInSeconds);
try {
wait.until(expectation);
} catch (Exception e) {
throw new SeleniumOperationException("Timeout waiting for Page Load Request to complete.", e);
}
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project ats-framework by Axway.
the class AbstractHtmlEngine method switchToWindowByTitle.
private void switchToWindowByTitle(final String windowTitle, long timeoutInSeconds) {
ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return switchToWindowByTitle(windowTitle);
}
};
Wait<WebDriver> wait = new WebDriverWait(webDriver, timeoutInSeconds);
try {
wait.until(expectation);
} catch (Exception e) {
throw new SeleniumOperationException("Timeout waiting for Window with title '" + windowTitle + "' to appear.", e);
}
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project geode by apache.
the class PulseTestUtils method waitForElement.
public static WebElement waitForElement(By by) {
WebElement element = (new WebDriverWait(driverProvider.get(), maxWaitTime)).until((ExpectedCondition<WebElement>) d -> d.findElement(by));
assertNotNull(element);
return element;
}
use of org.openqa.selenium.support.ui.ExpectedCondition in project ORCID-Source by ORCID.
the class OauthAuthorizationPageHelper method authorizeOnAlreadyLoggedInUser.
public static String authorizeOnAlreadyLoggedInUser(final WebDriver loggedInDriver, String baseUrl, String clientId, String redirectUri, String scopes, String stateParam) {
String formattedAuthorizationScreen = String.format(authorizationScreenUrl, baseUrl, clientId, scopes, redirectUri);
if (!PojoUtil.isEmpty(stateParam)) {
formattedAuthorizationScreen += "&state=" + stateParam;
}
loggedInDriver.get(formattedAuthorizationScreen);
try {
BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfElementLocated(By.xpath("//p[contains(text(),'has asked for the following access to your ORCID Record')]")), loggedInDriver);
By authorizeElementLocator = By.id("authorize");
(new WebDriverWait(loggedInDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(authorizeElementLocator));
WebElement authorizeButton = loggedInDriver.findElement(By.id("authorize"));
authorizeButton.click();
(new WebDriverWait(loggedInDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().equals("ORCID Playground");
}
});
} catch (TimeoutException e) {
// It might be the case that we are already in the ORCID Playground page, so, lets check for that case
(new WebDriverWait(loggedInDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().equals("ORCID Playground");
}
});
}
String result = loggedInDriver.getCurrentUrl();
return result;
}
Aggregations