clicking a page object that is required: false

107 views
Skip to first unread message

stuplum

unread,
Oct 3, 2017, 6:40:19 AM10/3/17
to Geb User Mailing List
I was wondering what the expected outcome should be of attempting to click on an element that does not exist within a page, but has the `required: false` option applied to it.

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
  }
}


When the button doesn't exist on `SomePage` the test is still reaching the `at` check for `AnotherPage`, I would have thought that an exception would have been thrown when the button element is missing and can't be clicked.


Marcin Erdmann

unread,
Oct 3, 2017, 5:35:49 PM10/3/17
to Geb User Mailing List
Hi,

Thanks for reporting. This looks like an oversight, especially as all click() overloads on EmptyNavigator apart from the one taking no arguments are actually throwing UnsupportedOperationException, see https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/navigator/EmptyNavigator.groovy#L51.

This is a potentially breaking change but I'm looking into releasing 2.0 anyway so we could fix it in that release. I need to make a bunch of other breaking changes due to upgrading to WebDriver 3.x which requires Java 8 and Geb was until now built with Java 7 hence the need for a new major version.

Would you mind creating an issue for this in the tracker at https://github.com/geb/issues/issues

Cheers,
Marcin

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/6473dd1f-5120-46f9-becc-4c4e404c3b66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

stuplum

unread,
Oct 4, 2017, 5:24:00 AM10/4/17
to Geb User Mailing List
Sure no problem
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages