I use Scala 2.10, Specs2 13.1-SNAPSHOT and the FluentLenium Api provided by Play2 Framework 2.1.
I have this line of code in my IntegrationSpec
file, finding a child element (according to FluentLenium spec):
browser.find(".myClass").find("#mySubElement") must haveSize(1)
That line leads to the following compilation error:
error: type mismatch;
found : org.fluentlenium.core.domain.FluentList[_ <: org.fluentlenium.core.domain.FluentWebElement]
required: org.fluentlenium.core.domain.FluentList[?0(in value $anonfun)] where type ?0(in value $anonfun) <: org.fluentlenium.core.domain.FluentWebElement
Note: org.fluentlenium.core.domain.FluentWebElement >: ?0, but Java-defined class FluentList is invariant in type E.
You may wish to investigate a wildcard type such as `_ >: ?0`. (SLS 3.2.10)
Is it a kind of...incompatibilty Scala/Java due to generics?? or a normal behaviour that I didn't figure out?
This line however (omitting any matcher), well compiles:
browser.find(".myClass").find("#mySubElement")
The
haveSize
matcher require the element being matched to have anorg.specs2.data.Sized
typeclass in scope. The corresponding typeclass for java collections is:I suspect that type inference here is the issue and you could try to tame it with the following ugly code:
Or maybe
Or