不是抽象的,并且不会覆盖Function中的抽象方法apply(Object)

时间:2013-01-05 07:23:30

标签: java selenium

我想等到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/

1 个答案:

答案 0 :(得分: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>(){ ...进行预测吗?