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

GStrings in attribute selectors do not work #525

Closed
robaca opened this Issue May 29, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@robaca

robaca commented May 29, 2018

It should be possible to pass GStrings for attribute values.

The following content definition does not resolve:

accountLink { id -> $('a', href: "/account/$id/profile") }

but the following does:

accountLink { id -> $('a', href: "/account/$id/profile" as String) }

It took me an hour to find the problem, as I just did expect id had to work.

@erdi

This comment has been minimized.

Member

erdi commented May 29, 2018

@robaca

This comment has been minimized.

robaca commented May 29, 2018

@erdi I tried with geb-spock 2.0 and 2.1 (groovy 2.4.10)

@erdi

This comment has been minimized.

Member

erdi commented May 29, 2018

@erdi

This comment has been minimized.

Member

erdi commented May 29, 2018

Thanks for reporting, this indeed was a bug.

The issue was more obscure than simply selection for GString attributes not working at all. Translation between attribute maps and css selectors indeed did not work for GString attributes which meant that it fell back to filtering in the JVM by retrieving attributes and then checking that against the provided value. In general filtering still worked but with somehow downgraded performance if you used GString attributes. It did not work anymore if the value returned for an attribute was different when retrieved using WebDriver commands from what was being matched using css selectors. The href attribute is one example because when retrieved using WebDriver the protocol and hostname are prepended to its value but protocol and hostname are not required when matching using a css attribute selector. So you were somewhat unlucky to encounter the issue but on the other hand thanks to that happening it has been discovered and is now fixed.

@erdi erdi self-assigned this May 30, 2018

@erdi erdi added the Bug label May 30, 2018

@erdi erdi added this to the 2.2 milestone May 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment