All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.magentys.cinnamon.webdriver.conditions.AjaxFinishedCondition Maven / Gradle / Ivy

package io.magentys.cinnamon.webdriver.conditions;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;

public class AjaxFinishedCondition extends Condition {

    @Override
    public boolean apply(WebDriver webDriver) {
        try {
            final JavascriptExecutor js = (JavascriptExecutor) webDriver;
            return (Boolean) js.executeScript("return (typeof jQuery !== 'undefined' ? jQuery.active == 0 : true);");
        } catch (WebDriverException e) {
            return false;
        }
    }

    @Override
    public String toString() {
        return "ajax finished";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy