Example usage for org.openqa.selenium PageLoadStrategy EAGER

List of usage examples for org.openqa.selenium PageLoadStrategy EAGER

Introduction

In this page you can find the example usage for org.openqa.selenium PageLoadStrategy EAGER.

Prototype

PageLoadStrategy EAGER

To view the source code for org.openqa.selenium PageLoadStrategy EAGER.

Click Source Link

Usage

From source file:com.seleniumtests.uipage.PageObject.java

License:Apache License

private void waitForPageToLoad() {
    try {//from   w  ww.  j  ava  2  s  .c o  m
        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;
    }
}

From source file:com.seleniumtests.ut.core.TestSeleniumTestContext.java

License:Apache License

@Test(groups = "ut context")
public void testPageLoadStrategy(final ITestContext testNGCtx, final XmlTest xmlTest) {
    initThreadContext(testNGCtx);/*w w w  . j av  a2s .  com*/
    SeleniumTestsContextManager.getThreadContext().setPageLoadStrategy("eager");
    Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getPageLoadStrategy(),
            PageLoadStrategy.EAGER);
}