geb withconfirm throwing 没有方法签名:geb.navigator.NonEmptyNavigator.getJs()?

geb withconfirm throwing No signature of method: geb.navigator.NonEmptyNavigator.getJs()?

我创建了一个简单的 hello world 应用程序,这里是使用确认块进行测试的规范。

https://github.com/learningcscience/confirmgeb/blob/master/src/integration-test/groovy/booktest/BookSpec.groovy

功能测试运行时报错

No signature of method: geb.navigator.NonEmptyNavigator.getJs() is applicable for argument types: () values: []
Possible solutions: getX(), getY(), getX(), getY(), getAt(groovy.lang.EmptyRange), getAt(groovy.lang.Range)
groovy.lang.MissingMethodException: No signature of method: geb.navigator.NonEmptyNavigator.getJs() is applicable for argument types: () values: []
Possible solutions: getX(), getY(), getX(), getY(), getAt(groovy.lang.EmptyRange), getAt(groovy.lang.Range)
    at geb.navigator.NonEmptyNavigator.methodMissing(NonEmptyNavigator.groovy:558)
    at geb.content.PageContentSupport.methodMissing(PageContentSupport.groovy:35)

抛出错误的那一行是withConfirm块。为什么会抛出这个错误?根据文档

The first method, withConfirm() (and its ‘ok’ defaulted relative), is used to verify actions that will produce a confirm dialog. This method returns the confirmation message. The ok parameter controls whether the “OK” or “Cancel” button should be clicked.

文档中的示例是

assert withConfirm(true) { $("input", name: "showConfirm").click() } == "Do you like Geb?"

http://www.gebish.org/manual/2.3/

感谢任何帮助。谢谢!

如果相关,我正在使用以下版本 chrome 驱动程序。

webdriverBinaries {
    chromedriver {
        version = '100.0.4896.20'
        architecture = 'X86'
    }
    geckodriver '0.24.0'
}

缺少的方法应指向 js-object (https://www.gebish.org/manual/current/#js-object)。

您使用的是一些过时的版本。将某些依赖项更新到 build.gradle 中的一致级别后,测试将 运行.

testCompile "org.seleniumhq.selenium:selenium-remote-driver:3.141.59"
testCompile "org.seleniumhq.selenium:selenium-api:3.141.59"
testCompile "org.seleniumhq.selenium:selenium-support:3.141.59"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.141.59"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.141.59"
testCompile 'org.gebish:geb-core:4.1'
testCompile 'org.gebish:geb-spock:4.1'

然后你可以向你的规范添加断言 (BookSpec):

withConfirm(true) {
    $("#btn").click()
}

顺便说一句。我们的 grailsw 已过时:https://grails.org/blog/2021-06-10-grails-wrapper-update.html