-1

我想等到一个js脚本返回true,我正在使用的代码没有编译并抛出错误

is not abstract and does not override abstract method apply(Object) in Function

这是代码

WebDriverWait wait = new WebDriverWait(driver, 10);
        boolean isFound = wait.until(new ExpectedCondition(){ //here ERROR
            public Boolean apply(WebDriver d){
                JavascriptExecutor js = (JavascriptExecutor) d;
                return (Boolean) js.executeScript("return true");
            }
        });

我试图从 http://www.tarnowski.se/2011/09/11/converting-selenium-waitforcondition-to-webdriverwait/复制代码

4

1 回答 1

1

代替

        public Boolean apply(WebDriver d){
            JavascriptExecutor js = (JavascriptExecutor) d;
            return (Boolean) js.executeScript("return true");
        }

尝试

        public Boolean apply(Object d){
            JavascriptExecutor js = (JavascriptExecutor) d;
            return (Boolean) js.executeScript("return true");
        }

Function 类/接口需要在您创建的子类中使用具有此签名的方法。

如果有raw types警告,也许new ExpectedCondition<WebDriver>(){ ...是你应该做的?

于 2013-01-05T07:31:39.827 回答