// Path: src/main/java/io/qameta/htmlelements/exception/WebPageException.java
// public class WebPageException extends RuntimeException {
// 
//     public WebPageException(String message) {
//         super(message);
//     }
// }


import io.qameta.htmlelements.exception.WebPageException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
package io.qameta.htmlelements.util;


/**
 * @author ehborisov
 */
public class WebDriverUtils {

    public static boolean pageIsLoaded(WebDriver webDriver) {
        if (webDriver instanceof JavascriptExecutor) {
                Object result = ((JavascriptExecutor) webDriver)
                        .executeScript("if (document.readyState) return document.readyState;");
                return result != null && "complete".equals(result);
        } else {
// Path: src/main/java/io/qameta/htmlelements/exception/WebPageException.java
// public class WebPageException extends RuntimeException {
// 
//     public WebPageException(String message) {
//         super(message);
//     }
// }


// Path: src/main/java/io/qameta/htmlelements/util/WebDriverUtils.java
import io.qameta.htmlelements.exception.WebPageException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;

package io.qameta.htmlelements.util;


/**
 * @author ehborisov
 */
public class WebDriverUtils {

    public static boolean pageIsLoaded(WebDriver webDriver) {
        if (webDriver instanceof JavascriptExecutor) {
                Object result = ((JavascriptExecutor) webDriver)
                        .executeScript("if (document.readyState) return document.readyState;");
                return result != null && "complete".equals(result);
        } else {
            throw new WebPageException("Driver must support javascript execution");