List of usage examples for org.openqa.selenium.support.ui ExpectedConditions jsReturnsValue
public static ExpectedCondition<Object> jsReturnsValue(final String javaScript)
From source file:com.liferay.faces.portal.test.showcase.inputrichtext.InputRichTextTester.java
License:Open Source License
@Override protected void navigateToUseCase(BrowserDriver browserDriver, String componentPrefix, String componentName, String componentUseCase) { browserDriver.navigateWindowTo(SHOWCASE_CONTEXT_URL + "/" + componentPrefix + "/" + componentName.toLowerCase(Locale.ENGLISH) + "/" + componentUseCase); waitForShowcasePageReady(browserDriver); // TECHNICAL NOTE: Wait until all CKEditors are ready to be tested. browserDriver//from ww w. j av a 2 s .c o m .waitFor(ExpectedConditions.jsReturnsValue("if (CKEDITOR && CKEDITOR.instances) { return true; }")); //J- browserDriver.waitFor(ExpectedConditions.jsReturnsValue("for (var ckeditorKey in CKEDITOR.instances) {" + "if (!CKEDITOR.instances[ckeditorKey].instanceReady) {" + "return null;" + "}" + "}" + "return true;")); //J+ }
From source file:com.liferay.faces.portal.test.showcase.inputrichtext.InputRichTextTester.java
License:Open Source License
protected final void submitRichText(BrowserDriver browserDriver, String elementToClickXpath, int ckeditorExampleNumber, String expectedText) { browserDriver.getWebDriver().switchTo().parentFrame(); //J-// w w w . j a va 2s. c o m browserDriver.executeScriptInCurrentWindow("for (var ckeditorKey in CKEDITOR.instances) {" + "CKEDITOR.instances[ckeditorKey].updateElement();" + "}"); //J+ try { browserDriver.setWaitTimeOut(1); WebElement textarea = browserDriver.findElementByXpath( "(//textarea[contains(@id,':comments_input')])[" + ckeditorExampleNumber + "]"); //J- browserDriver.waitFor( ExpectedConditions.jsReturnsValue("if (document.getElementById('" + textarea.getAttribute("id") + "').value" + "=== '" + expectedText + "') {" + "return true;" + "}")); //J+ } catch (TimeoutException e) { // Do nothing. } browserDriver.setWaitTimeOut(TestUtil.getBrowserDriverWaitTimeOut()); browserDriver.clickElement(elementToClickXpath); }
From source file:com.liferay.faces.test.showcase.TesterBase.java
License:Open Source License
protected void waitForShowcasePageReady(BrowserDriver browserDriver) { browserDriver.waitFor(ExpectedConditions.jsReturnsValue("return window.liferay_faces_showcase_ready;")); }
From source file:com.seleniumtests.uipage.PageObject.java
License:Apache License
private void waitForPageToLoad() { try {/*from w w w . j a va 2 s. c om*/ if (robotConfig().getPageLoadStrategy() == PageLoadStrategy.NORMAL) { new WebDriverWait(driver, 5).until(ExpectedConditions .jsReturnsValue("if (document.readyState === \"complete\") { return \"ok\"; }")); } else if (robotConfig().getPageLoadStrategy() == PageLoadStrategy.EAGER) { new WebDriverWait(driver, 5).until(ExpectedConditions .jsReturnsValue("if (document.readyState === \"interactive\") { return \"ok\"; }")); } } catch (TimeoutException e) { // nothing } // populate page info try { capturePageSnapshot(); } catch (Exception ex) { logger.error(ex); throw ex; } }