我可以直接在GEB测试中使用WebDriver API吗?

时间:2014-08-27 05:57:55

标签: java webdriver geb

在使用GEB框架编写自动化测试时,我可以直接使用Webdriver API吗?例如,有些事情如下:

WebElmenent element=driver.findElement(By.xpath("//input..."))
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
  .until(ExpectedConditions.visibilityOf(element));

是否可以直接使用WebDriver API?

谢谢,

Raghuveer。

2 个答案:

答案 0 :(得分:0)

 public static void waitForElementToAppear(Driver driver, By selector, long timeOutInSeconds, String timeOutMessage) {
    try {
      WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
      wait.until(ExpectedConditions.visibilityOfElementLocated(selector));
    } catch (TimeoutException e) {
      throw new IllegalStateException(timeOutMessage);
    }
  }

答案 1 :(得分:0)

虽然Geb允许您直接访问Webdriver apis,但它不支持xpath,这通常被认为是一件好事。 Geb的css选择器是它的优势之一,应该允许你做任何你喜欢用xpath做的事情。如果您对css和/或jQuery非常熟悉,那么学习Geb语法的时间应该相对简短。