Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何向函数发送预期条件?_Java_Selenium - Fatal编程技术网

Java 如何向函数发送预期条件?

Java 如何向函数发送预期条件?,java,selenium,Java,Selenium,我想编写一个获取ExpectedConditions和Locator的通用函数: public WebElement findElementElements(ExpectedConditions expectedConditions, By locator){ WebDriver driver... WebDriverWait webDriverWait... return driver.webDriverWait().until(expectedConditions(

我想编写一个获取
ExpectedConditions
Locator
的通用函数:

public WebElement findElementElements(ExpectedConditions expectedConditions, By locator){
    WebDriver driver...
    WebDriverWait webDriverWait...

    return driver.webDriverWait().until(expectedConditions(locator));
}

但是我得到了这个编译器错误:“预期的方法调用”

不是所有的
expectedconditions
都返回相同的类型。。。一些返回
WebElement
,其他返回
Boolean
。此方法需要
ExpectedConditions
返回
WebElement
s

public WebElement findElement(Function<WebDriver, WebElement> expectedCondition) {
    return new WebDriverWait(driver, 10).until(expectedCondition);
}

注意:您不需要
locator
参数,因为这是
ExpectedCondition

的必需部分,您打算
expectedConditions(locator)
做什么?您没有指定要调用哪个方法。另外,至少要显示真实的完整代码和完整的错误消息。在没有看到实际代码的情况下,很难调试您的问题或猜测您打算做什么。@JoachimSauer我猜他是在询问将接收
expectedConditions
locator
参数并返回传递的
locator
定位的元素并满足所需条件的通用方法
预期条件
如可见性、可点击性等条件。
WebElement e = findElement(ExpectedConditions.elementToBeClickable(By.id("myId")));