Solution 1 :

I use PageFactory with AjaxElementLocatorFactory – PageFactory is a support class for the 2 Page Objects pattern which you are using, and the AjaxElementLocatorFactory is the factory for the element locators. In your case the constructor will looks like:

public GoogleResultsPage() { 
    PageFactory.initElements(new AjaxElementLocatorFactory(driver, 15), this);
}

This code will wait maximum of 15 seconds until the elements specified by annotations will appear on the page, in your case the homePageLink which will be located by xpath. You will not need to use ElementPresent class.

AjaxElementLocatorFactory uses SlowLoadableComponent internally.

Solution 2 :

static void waitForPageLoad( wdriver) {
    WebDriverWait wait = new WebDriverWait(wdriver, 60);

    Predicate<> pageLoaded = new Predicate<>() {

        @Override
        public boolean apply( input) {
            return ((JavascriptExecutor) input).executeScript("return document.readyState").equals("complete");
        }

    };
    wait.until(pageLoaded);
}

Give a try, Hope it helps!



Source link https://sqa.stackexchange.com/questions/18297/selenium-webdriver--is--after--

LEAVE A REPLY

Please enter your comment!
Please enter your name here