FluentWait函数不能用于Java类的功能

时间:2013-12-05 04:29:19

标签: java eclipse selenium

这可能是一个基本问题,但我对Java和Selenium Webdriver不太熟悉。我不知道为什么Eclipse在Eclipse中将'Function'更改为'Remove type arguments'时显示Error。我想在我的班级中使用fluentwait作为函数。或者使用它的正确方法是什么?

public class Process()
   {
    public void Start()
    {
        //function call
        WebElement index = fluentWait(By.xpath("xxx"), driver);
    }   

    //function method
    public WebElement fluentWait(final By locator, WebDriver driver) {
        Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
                .withTimeout(30, TimeUnit.SECONDS)
                .pollingEvery(5, TimeUnit.SECONDS)
                .ignoring(NoSuchElementException.class);

        WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
            public WebElement apply(WebDriver driver) {
                return driver.findElement(locator);
            }
        });

        return  foo;
    };
   }

1 个答案:

答案 0 :(得分:2)

您似乎无法导入com.google.common.base.Function