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

MissingMethodException in 0.13.0 when setting input field value with value() #422

Closed
craigatk opened this Issue Feb 17, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@craigatk

craigatk commented Feb 17, 2016

I get this exception when trying to set an input field's value with the .value() method in a company project I'm working on. I tried to reproduce the issue in a public project to give a reproducible example but it works fine in the public project, which is inconvenient.

|  groovy.lang.MissingMethodException: No signature of method: java.util.HashMap$Values.minus() is applicable for argument types: (java.util.ArrayList) values: [[input, select, textarea]]
Possible solutions: min(), min(groovy.lang.Closure), min(java.util.Comparator), find(), find(), unique()
    at geb.navigator.NonEmptyNavigator.setInputValues(NonEmptyNavigator.groovy:704)
    at geb.navigator.NonEmptyNavigator.value(NonEmptyNavigator.groovy:448)
    at geb.content.TemplateDerivedPageContent.value(TemplateDerivedPageContent.groovy:33)

NonEmptyNavigator.groovy line 704 is

def unsupportedElements = inputsToTagNames.values() - ELEMENTS_WITH_MUTABLE_VALUE

link https://github.com/geb/geb/blob/0a2f45c9b70da018597f0847e230363be20e8bc0/module/geb-core/src/main/groovy/geb/navigator/NonEmptyNavigator.groovy#L704

In the past I've been bitten by HashMap.values() not being a normal collection type (List, Set, etc.) - it's a special class Values inside HashMap that doesn't have all the same collection methods as some of the more common collection classes.

From looking at what methods the Values class does have, it looks like it has the removeAll() method which could be a good substitute in this case.

@craigatk

This comment has been minimized.

craigatk commented Feb 17, 2016

I'll try to reproduce the exception with a test in Geb core and if I can I'll submit a PR to fix it.

@craigatk

This comment has been minimized.

craigatk commented Feb 17, 2016

I haven't been able to reproduce the issue in a test inside Geb core yet, but I was able to reproduce it in a public Grails2 project: https://github.com/craigatk/geb-example

@craigatk

This comment has been minimized.

craigatk commented Feb 17, 2016

I think I know why I'm getting this exception in my Grails2 apps but can't recreate in Geb core - different Groovy versions.

I added a test to the geb-grails plugin that calls .value() and messed around with specifying different Groovy versions in geb-grails.gradle. Currently project.groovyVersion is in there, which is 2.4.5. When I changed the Groovy version to what ships with Grails 2.4.2 (Groovy 2.3.7), then I got the exception. I tried some different versions and any Groovy version >= 2.4.0 works fine so they must have added more methods for that HashMap.Values class in Groovy 2.4.0

Now that I have a way to reproduce and test the fix I will work on a PR to fix it to work with Groovy < 2.4

@erdi

This comment has been minimized.

Member

erdi commented Feb 17, 2016

Thanks for reporting and looking into this, @craigatk. I'm a bit busy tonight and tomorrow so I might not be able to attend to it before Friday, sorry about that. Looking forward to the PR, though.

@craigatk

This comment has been minimized.

craigatk commented Feb 17, 2016

@erdi no problem, looking into it by the weekend is still quick! :)

I created a PR with a fix here geb/geb#115

If there's anything I should change in the PR or do differently, just let me know. Thanks!

@erdi

This comment has been minimized.

Member

erdi commented Feb 17, 2016

That was quick, thanks. I will comment on the PR.

@erdi erdi added the Bug label Feb 20, 2016

@erdi erdi self-assigned this Feb 20, 2016

@erdi erdi added this to the 0.13.1 milestone Feb 20, 2016

@erdi erdi closed this Feb 20, 2016

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