Geb - IncompatibleClassChangeError

时间:2011-10-19 19:27:16

标签: java groovy geb

我刚刚开始使用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)
        .......

有什么想法吗?谢谢!

2 个答案:

答案 0 :(得分:12)

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

答案 1 :(得分:1)

从0.7.1开始,Geb与Java7兼容。如果你低于那个,你应该升级。 SEe:http://jira.codehaus.org/browse/GEB-194