Selenium webdriver Selenium 2中是否有WaitForText或WaitForElement方法?

Selenium webdriver Selenium 2中是否有WaitForText或WaitForElement方法?,selenium-webdriver,Selenium Webdriver,我找到了WaitForPageToLoad、WaitForCondition和popup。我有一个ajax请求,它正在创建一些新元素。使用WaitForElement Check我在Java中使用此代码-它检查指定元素3秒钟(可配置): WebDriverWait wait = new WebDriverWait(driver, /*seconds=*/3); elementOfPage = wait.until(presenceOfElementLocated(By.id("id_o

我找到了WaitForPageToLoad、WaitForCondition和popup。我有一个ajax请求,它正在创建一些新元素。

使用WaitForElement


Check

我在Java中使用此代码-它检查指定元素3秒钟(可配置):

 WebDriverWait wait = new WebDriverWait(driver, /*seconds=*/3);
    elementOfPage = wait.until(presenceOfElementLocated(By.id("id_of_element")));


 Function<WebDriver, WebElement> presenceOfElementLocated(final By locator) {
  return new Function<WebDriver, WebElement>() {
        public WebElement apply(WebDriver driver) {
            return driver.findElement(locator);
        }
    };
}
WebDriverWait wait=newwebdriverwait(驱动程序,/*秒=*/3);
elementOfPage=wait.until(元素的存在位置)(By.id(“元素的id”));
定位元件的功能显示(最终由定位器确定){
返回新函数(){
公共WebElement应用(WebDriver){
返回驱动程序findElement(定位器);
}
};
}