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

205 views Asked by At

I have created a simple hello world app and here is the spec to test withconfirm block.

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

It is throwing the error when i run the functional test.

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)

The line where the error is thrown is the withConfirm block. Why is it throwing this error? According to the docs

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.

and the example from the docs is

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

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

I appreciate any help. Thanks!

If it is relevant i am using the following version chrome driver.

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

There are 1 answers

3
Stefan Hildebrandt On BEST ANSWER

The missing method should point to the js-object (https://www.gebish.org/manual/current/#js-object).

You are using some outdated versions. After Update some dependencies to a consistent level in the build.gradle, the tests will run.

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'

Than you can add a assertion to your spec (BookSpec):

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

Btw. our grailsw is outdated: https://grails.org/blog/2021-06-10-grails-wrapper-update.html