3

我刚开始使用 Geb,在输入来自 Geb 的示例代码时遇到此错误:

import geb.Browser


Browser.drive {
    go "http://google.com/ncr"

    // make sure we actually got to the page
    assert title == "Google"

    // enter wikipedia into the search field
    $("input", name: "q").value("wikipedia")

    // wait for the change to results page to happen
    // (google updates the page dynamically without a new request)
    waitFor { title.endsWith("Google Search") }

    // is the first link to wikipedia?
    def firstLink = $("li.g", 0).find("a.l")
    assert firstLink.text() == "Wikipedia"

    // click the link
    firstLink.click()

    // wait for Google's javascript to redirect to Wikipedia
    waitFor { title == "Wikipedia" }
}

我遇到了这个异常:

Caught: java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 4 but got 5
    at geb.error.GebException.<init>(GebException.groovy:20)
    at geb.waiting.WaitTimeoutException.<init>(WaitTimeoutException.groovy:30)
    at geb.waiting.Wait.waitFor(Wait.groovy:108)
        .......

有任何想法吗?谢谢!

4

2 回答 2

12

您是否有机会使用 Java 7?使用使用 < Java 7 编译的异常的 Groovy 代码与 Java 7 不兼容。

于 2011-10-19T20:32:54.940 回答
1

Geb 自 0.7.1 起与 Java7 兼容。如果你低于这个值,你应该升级。参见: http ://jira.codehaus.org/browse/GEB-194

于 2013-02-12T13:50:12.187 回答