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

org.jbehave.web.selenium.GroovyFluentWebDriverPage.groovy Maven / Gradle / Ivy

There is a newer version: 4.0-beta-1
Show newest version
package org.jbehave.web.selenium

import com.github.tanob.groobe.GrooBe
import org.openqa.selenium.support.ui.WebDriverWait
import java.util.concurrent.TimeUnit
import org.openqa.selenium.WebDriver
import com.google.common.base.Predicate
import org.openqa.selenium.NoSuchElementException
import static java.util.Arrays.asList

public class GroovyFluentWebDriverPage extends FluentWebDriverPage {

    public GroovyFluentWebDriverPage(WebDriverProvider driverProvider) {
        super(driverProvider);
        GrooBe.activate()
    }

    def waitFor(int timeout, int retry, Class... ignoreThese = new Class[0], Closure block) {
        def get = getDriverProvider().get()
        def wdw = new WebDriverWait(get, timeout)
                        .pollingEvery(retry, TimeUnit.MILLISECONDS)
                        .ignoreAll(asList(ignoreThese))
                        .ignoring(NoSuchElementException.class) // standard
        return wdw.until(new Predicate() {
            boolean apply(WebDriver wd) {
                block()
            }
        })
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy