Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clicking on non existent element does not throw error #501

Closed
stuplum opened this Issue Oct 4, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@stuplum
Copy link

stuplum commented Oct 4, 2017

Given this page:

class SomePage {
    ...
    static content = {
        button(required: false) { $('.some-incorrect-selector').module(SomeButtonModule) }
        ...
    }
}

and given this Spec:

class SomeSpec {

    def 'Clicking on the button should take user to AnotherPage' () {

        given:
            def page = to SomePage

        when:
            page.button.click()

        then:
            at AnotherPage
    }
}

Expected behaviour:
An exception should be thrown when the button element is missing and can't be clicked.

Actual behaviour:
When the button doesn't exist on SomePage the test is still reaching the at check for AnotherPage

@erdi erdi added this to the 1.2 milestone Oct 5, 2017

@erdi

This comment has been minimized.

Copy link
Member

erdi commented Oct 5, 2017

Created from the following mailing list thread: https://groups.google.com/forum/#!topic/geb-user/pYqGUq9oHq4.

fsobanski added a commit to iteratec/OpenSpeedMonitor that referenced this issue May 14, 2018

[IT-1681] Geb Test: Don't click on non-existent element
Geb has made the following change in its new version:
geb/issues#501
Previously, nothing would happen if you would call click() on a
non-existent element.

I suppose that the element with had the id pointTwo when our geb
test was written. And at some point, the id changed to pointTwo.id
but our geb test never noticed because clicking on a non-existent
element would not throw an error.

Now that we are using the new geb version, I am also updating the
selector to fix the test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.