class attribute selector does not work in GEB 0.12.0 #390

fabriziofortino opened this Issue Jul 14, 2015 · 3 comments


None yet

3 participants


I am trying to migrate to 0.12.0 but I stumbled in a problem with the class attribute selector. I have a Module with the following content:

static content = {
  userMenuButton { $('a', class: 'user-menu-button') }

The above code works with GEB 0.10.0 but throws the following exception with 0.12.0:

geb.error.RequiredPageContentNotPresent: The required page content 'userMenuButton - SimplePageContent (owner: module.UserMenuModule@4c2d610, args: [], value: null)' is not present
at geb.content.TemplateDerivedPageContent.require(TemplateDerivedPageContent.groovy:68)
at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:67)
at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy)
at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:86)
at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:58)
at geb.content.DefaultPageContentSupport.getContent(DefaultPageContentSupport.groovy:42)
at geb.content.PageContentSupport.propertyMissing(PageContentSupport.groovy:39)
at geb.Module.propertyMissing(Module.groovy:101)
at module.UserMenuModule.logout(UserMenuModule.groovy:17)
at geb.content.TemplateDerivedPageContent.methodMissing(TemplateDerivedPageContent.groovy:128)
at spec.authentication.LoginLogoutSpec.can logout from MyApp(LoginLogoutSpec.groovy:37)

It works if I change the code without using the class attribute:

static content = {
  userMenuButton { $('a.user-menu-button') }

Please notice that the element has multiple classes.


I'm just finding my way around Geb, so I apologize if I'm out of line here, but shouldn't that be:

static content = {
    userMenuButton { $('a', class:contains('user-menu-button') }

I believe that looking for class as you have in your OP fails because of the additional classes.

erdi commented Jul 14, 2015

No @treyturner, it should work the way @fabriziofortino expects it to work. That was the behaviour prior to 0.12.0 and it is a bug I introduced while working on #280.


Doh, I could swear I had problems selecting this way in 0.10.0. Good to know though, I'll stay at 0.10.0 for now, thanks.

@erdi erdi added this to the 0.12.1 milestone Jul 14, 2015
@erdi erdi added a commit to geb/geb that closed this issue Aug 2, 2015
@erdi erdi Properly handle class attribute when it's passed to `$()` together wi…
…th a css selector.

Closes geb/issues#390
@erdi erdi added the Bug label Aug 2, 2015
@erdi erdi self-assigned this Aug 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment