List of usage examples for org.openqa.selenium.html5 AppCacheStatus DOWNLOADING
AppCacheStatus DOWNLOADING
To view the source code for org.openqa.selenium.html5 AppCacheStatus DOWNLOADING.
Click Source Link
From source file:org.auraframework.integration.test.http.AppCacheResourcesLoggingUITest.java
License:Apache License
/** * Load and get all the log lines for the app load. Some sanity checks that our simple test app is functional after * cache resolutions./*from ww w. j a va2 s.c om*/ * <ul> * <li>updated markup text is rendered (markupToken)</li> * <li>updated client actions functional (jsToken)</li> * <li>updated styling applied (cssToken)</li> * <li>updated framework called (fwToken)</li> * </ul> * * @param markupToken The text to be found in the markup. * @param jsToken The text to be found from js * @param cssToken The text to be found from css. * @param fwToken The text to be found from the framework. */ private List<Request> loadMonitorAndValidateApp(final AppDescription app, final String markupToken, String jsToken, String cssToken, String fwToken, boolean waitForAura) throws Exception { appender.clearLogs(); // Opening a page through WebDriverTestCase adds a nonce to ensure fresh resources. In this case we want to see // what's cached, so build our URL and call WebDriver.get() directly. String url = getUrl(app); Map<String, String> params = new HashMap<>(); params.put("aura.mode", getAuraModeForCurrentBrowser().toString()); url = getAbsoluteURI(addUrlParams(url, params)).toString(); if (waitForAura) { open(url); } else { getDriver().get(url); } getAuraUITestingUtil().waitUntilWithCallback(new Function<WebDriver, Integer>() { @Override public Integer apply(WebDriver input) { String script = "return window.applicationCache.status;"; int appCacheStatus = Integer.parseInt(getAuraUITestingUtil().getEval(script).toString()); if (appCacheStatus != AppCacheStatus.DOWNLOADING.value() && appCacheStatus != AppCacheStatus.CHECKING.value()) { return appCacheStatus; } else { return null; } } }, new ExpectedCondition<String>() { @Override public String apply(WebDriver d) { String script = "return window.applicationCache.status;"; int appCacheStatus = Integer.parseInt(getAuraUITestingUtil().getEval(script).toString()); return "Current AppCache status is: " + AppCacheStatus.getEnum(appCacheStatus).toString(); } }, 10, "Application cache status is stuck on Downloading or Checking."); getAuraUITestingUtil().waitUntil(new Function<WebDriver, WebElement>() { @Override public WebElement apply(WebDriver input) { try { WebElement find = findDomElement(By.cssSelector(".clickableme")); if (markupToken.equals(find.getText())) { return find; } } catch (StaleElementReferenceException e) { // slight chance of happening between the findDomElement and getText } return null; } }, "fail to load clickableme"); Thread.sleep(200); List<Request> logs = parseLogs(appender.getLog()); String output = getAuraUITestingUtil().waitUntil(new Function<WebDriver, String>() { @Override public String apply(WebDriver input) { try { WebElement find = findDomElement(By.cssSelector(".clickableme")); find.click(); WebElement outputEl = findDomElement(By.cssSelector("div.attroutput")); return outputEl.getText(); } catch (StaleElementReferenceException e) { // could happen before the click or if output is // rerendering } return null; } }, "fail to click on clickableme or couldn't locate output value"); String expected = String.format("%s%s%s", jsToken, cssToken, fwToken); assertEquals("Unexpected alert text", expected, output); appender.clearLogs(); return logs; }