2011-09-14 35 views

回答

0

中声明的部分或全部字段我的解决方案是不使用@FindBy。

在你的页面对象:

By someElementLocator = By.cssSelector(".locator"); 

    public void waitForElementPresent(final By locator, int timeout) { 
    ExpectedCondition e = new ExpectedCondition<Boolean>() { 
     public Boolean apply(WebDriver driver) { 

      return driver.findElements(locator).size() > 0; 
     } 
    }; 

    WebDriverWait wait = new WebDriverWait(driver, timeout); 
    wait.until(e); 

} 

    public WebElement getSomeElement() { 
    waitForElementPresent(someElementLocator); 
    return driver.findElement(locator); 
    } 

也许这是一个建筑的问题。我似乎无法找到任何确认@FindBy支持等待的资源,所以它的使用取决于测试设计/体系结构。

相关问题