This is because the binding updater does not forward methods
from geb.textmatching.TextMatchingSupport onto the Browser instance. Would
you mind creating an issue for that in the tracker at
https://github.com/geb/issues/issues?
To workaround that issue you can override the BindingUpdater:
@InheritConstructors
class BindingUpdaterSupportingTextMatchers extends BindingUpdater {
static public final TEXT_MATCHING_FORWARDED_BROWSER_METHODS =
["contains"]
@Override
BindingUpdater initialize() {
super.initialize()
TEXT_MATCHING_FORWARDED_BROWSER_METHODS.each {
binding.setVariable(it, new
BindingUpdater.InvocationForwarding(it, browser))
}
this
}
@Override
BindingUpdater remove() {
super.remove()
TEXT_MATCHING_FORWARDED_BROWSER_METHODS.each {
binding.variables.remove(it)
}
this
}
}
and use that instead of the one provided out of the box. You will probably
want to add names of additional methods from TextMatchingSupport
to TEXT_MATCHING_FORWARDED_BROWSER_METHODS if you want them to work.
Another workaround would be not to use the matcher methods directly in your
steps but as part of page definitions using content DSL (
https://gebish.org/manual/current/#content-dsl). As far as I can tell,
using text matcher methods in content definitions should work for you
without any changes being needed.
On Wed, Nov 6, 2019 at 6:24 AM raz <[email protected]> wrote:
> Thanks Marcin,
>
> That seems to have fixed the StackOverFlow exception.
>
> Now I'm getting this exception
> groovy.lang.MissingMethodException: No signature of method: cucumber.
> runtime.groovy.GroovyWorld.contains() is applicable for argument types: (
> String) values: [q]
>
> when using
>
> browser.$('input', name: contains('q')) << term + Keys.ENTER
>
>
> instead of
> browser.$('input', name: 'q') << term + Keys.ENTER
>
> I have attached the updated project again (as per the example you shared),
> can you please let me know if it's setup as it should be? Am I missing an
> import to use shortcut pattern methods?
>
> Really appreciate your help.
>
> Thanks!
>
>
>
> On Saturday, 2 November 2019 00:24:22 UTC+11, Marcin Erdmann wrote:
>>
>> Raz,
>>
>> This is not a problem with Geb but it's down how you setup the
>> environment for your cucumber environment, namely mixing in the browser
>> class into them using this.metaClass.mixin(geb.Browser) which is something
>> you should never do. Instead you should setup your environment using the
>> BindingUpdater, as shown in the example project at
>> https://github.com/geb/geb-example-cucumber-jvm/blob/master/src/cucumber/resources/env/env.groovy.
>> After removing the mixing in and using the bundle updater I was able to get
>> the scenarios you attached to pass:
>>
>> [erdi@mbp ~/Downloads/testsuite-sandbox]$ mvn clean test
>> -Dgeb.env=chrome -DtagArg=@US01
>> [INFO] Scanning for projects...
>> [INFO]
>> [INFO] ---------------------< au.com.sandbox:sample-test
>> >---------------------
>> [INFO] Building sandbox-test 0.0.1
>> [INFO] --------------------------------[ jar
>> ]---------------------------------
>> [INFO]
>> [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ sample-test
>> ---
>> [INFO] Deleting /Users/erdi/Downloads/testsuite-sandbox/target
>> [INFO] Deleting /Users/erdi/Downloads/testsuite-sandbox/reports (includes
>> = [], excludes = [])
>> [INFO]
>> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
>> sample-test ---
>> [INFO] Using 'UTF-8' encoding to copy filtered resources.
>> [INFO] skip non existing resourceDirectory
>> /Users/erdi/Downloads/testsuite-sandbox/src/main/resources
>> [INFO]
>> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
>> sample-test ---
>> [INFO] No sources to compile
>> [INFO]
>> [INFO] --- maven-resources-plugin:2.6:testResources
>> (default-testResources) @ sample-test ---
>> [INFO] Using 'UTF-8' encoding to copy filtered resources.
>> [INFO] Copying 4 resources
>> [INFO]
>> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
>> sample-test ---
>> [INFO] No sources to compile
>> [INFO]
>> [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ sample-test
>> ---
>> [INFO] Tests are skipped.
>> [INFO]
>> [INFO] --- exec-maven-plugin:1.6.0:java (default) @ sample-test ---
>> [io.cucumber.core.cli.Main.main()] INFO
>> io.github.bonigarcia.wdm.WebDriverManager - Using chromedriver 78.0.3904.70
>> (since Google Chrome 78 is installed in your machine)
>> [io.cucumber.core.cli.Main.main()] INFO
>> io.github.bonigarcia.wdm.WebDriverManager - Exporting
>> webdriver.chrome.driver as
>> /Users/erdi/.m2/repository/webdriver/chromedriver/mac64/78.0.3904.70/chromedriver
>> [CONFIG] >>> Chrome Driver Version: 78.0.3904.70
>> Starting ChromeDriver 78.0.3904.70
>> (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800})
>> on port 46028
>> Only local connections are allowed.
>> Please protect ports used by ChromeDriver and related test frameworks to
>> prevent access by malicious code.
>> Nov 01, 2019 1:17:44 PM org.openqa.selenium.remote.ProtocolHandshake
>> createSession
>> INFO: Detected dialect: W3C
>> Results Found ==> About 1,090,000,000 results (0.87 seconds)
>>
>> 1 Scenarios (1 passed)
>> 2 Steps (2 passed)
>> 0m7.920s
>>
>>
>> On Mon, Oct 28, 2019 at 10:23 PM raz <[email protected]> wrote:
>>
>>> Hi Marcin,
>>>
>>> Thanks for getting back.
>>>
>>> I've attached a zip file of the whole project which should help you
>>> replicate the issue.
>>>
>>> Once extracted, following command can be used from home dir to run the
>>> test and you'll see the exception.
>>>
>>> mvn clean test -Dgeb.env=chrome -DtagArg=@US01
>>>
>>> Only setup required is maven, chrome and JDK1.8
>>>
>>> Please let me know if you need anything else, hopefully the issue is
>>> resolved soon!
>>>
>>>
>>> On Tuesday, 29 October 2019 07:57:22 UTC+11, Marcin Erdmann wrote:
>>>>
>>>> Hi Raz,
>>>>
>>>> You're the third person reporting a problem where Geb's private methods
>>>> and properties are mysteriously not seen from other places in the same
>>>> class when using Geb with Cucumber and Maven (for the other two see
>>>> https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/geb-user/pHZfjoPGECg/V9sAPmaWAwAJ).
>>>> Unfortunately the previous reporters did not manage to produce a minimal
>>>> reproducible sample that I could play with to observe the issue and debug
>>>> it. Maybe it's the third time lucky and you will be able to create
>>>> something that exposes the issue and upload it to github for me to be able
>>>> to take a look at?
>>>>
>>>> Thanks,
>>>> Marcin
>>>>
>>>> On Mon, Oct 28, 2019 at 8:14 AM raz <[email protected]> wrote:
>>>>
>>>>> I'm getting *java.lang.StackOverflowError* exception when using *waitFor
>>>>> *method (log file attached with full exception)
>>>>>
>>>>> Line of code throwing exception is
>>>>> waitFor(10) { browser.$('div', class: 'LocationSearch__ResultCount-jsWbXv
>>>>> hXPPML').isDisplayed() }
>>>>>
>>>>>
>>>>> But the following line works fine so I'm certain object can be found.
>>>>> while (!browser.$('div', class: 'LocationSearch__ResultCount-jsWbXv
>>>>> hXPPML').isDisplayed()) { System.out.println("waiting...") }
>>>>>
>>>>>
>>>>> I believe it has something to do with the clash of versions in POM
>>>>> file as the waitFor works fine if I update POM file to geb-core version
>>>>> 0.10.0 but anything higher than that causes the above issue.
>>>>>
>>>>> Here are the properties and dependencies from the POM file:
>>>>>
>>>>> <properties>
>>>>> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>>>>
>>>>> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>>>>>
>>>>>
>>>>> <cluecumber-report-plugin.version>2.3.1</cluecumber-report-plugin.version>
>>>>> <exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
>>>>> <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
>>>>> <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
>>>>> <ocular.version>1.0.0.Alpha</ocular.version>
>>>>> <groovycsv.version>1.3</groovycsv.version>
>>>>> <ashot.version>1.5.4</ashot.version>
>>>>> <webdrivermanager.version>3.7.1</webdrivermanager.version>
>>>>> <com4j.version>2.1</com4j.version>
>>>>> <geb-core.version>3.2</geb-core.version>
>>>>> <http-builder.version>0.7.1</http-builder.version>
>>>>> <commons-io.version>2.6</commons-io.version>
>>>>> <selenium-api.version>3.141.59</selenium-api.version>
>>>>> <selenium-java.version>3.141.59</selenium-java.version>
>>>>> <slf4j-simple.version>1.7.28</slf4j-simple.version>
>>>>> <cucumber-jvm.version>4.8.0</cucumber-jvm.version>
>>>>> <cucumber-groovy.version>4.2.0</cucumber-groovy.version>
>>>>> <groovy-all.version>2.5.8</groovy-all.version>
>>>>> </properties>
>>>>>
>>>>>
>>>>> <dependencies>
>>>>>
>>>>> <dependency>
>>>>> <groupId>io.cucumber</groupId>
>>>>> <artifactId>cucumber-groovy</artifactId>
>>>>> <version>${cucumber-groovy.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.codehaus.groovy</groupId>
>>>>> <artifactId>groovy-all</artifactId>
>>>>> <version>${groovy-all.version}</version>
>>>>> <type>pom</type>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>io.cucumber</groupId>
>>>>> <artifactId>cucumber-jvm</artifactId>
>>>>> <version>${cucumber-jvm.version}</version>
>>>>> <type>pom</type>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.slf4j</groupId>
>>>>> <artifactId>slf4j-simple</artifactId>
>>>>> <version>${slf4j-simple.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>io.github.bonigarcia</groupId>
>>>>> <artifactId>webdrivermanager</artifactId>
>>>>> <version>${webdrivermanager.version}</version>
>>>>> <scope>test</scope>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.seleniumhq.selenium</groupId>
>>>>> <artifactId>selenium-java</artifactId>
>>>>> <version>${selenium-java.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.seleniumhq.selenium</groupId>
>>>>> <artifactId>selenium-api</artifactId>
>>>>> <version>${selenium-api.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>commons-io</groupId>
>>>>> <artifactId>commons-io</artifactId>
>>>>> <version>${commons-io.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.codehaus.groovy.modules.http-builder</groupId>
>>>>> <artifactId>http-builder</artifactId>
>>>>> <version>${http-builder.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.gebish</groupId>
>>>>> <artifactId>geb-core</artifactId>
>>>>> <version>${geb-core.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>org.jvnet.com4j</groupId>
>>>>> <artifactId>com4j</artifactId>
>>>>> <version>${com4j.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>ru.yandex.qatools.ashot</groupId>
>>>>> <artifactId>ashot</artifactId>
>>>>> <version>${ashot.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>com.xlson.groovycsv</groupId>
>>>>> <artifactId>groovycsv</artifactId>
>>>>> <version>${groovycsv.version}</version>
>>>>> </dependency>
>>>>>
>>>>> <dependency>
>>>>> <groupId>com.testautomationguru.ocular</groupId>
>>>>> <artifactId>ocular</artifactId>
>>>>> <version>${ocular.version}</version>
>>>>> </dependency>
>>>>>
>>>>> </dependencies>
>>>>>
>>>>> <plugins>
>>>>> <plugin>
>>>>> <groupId>org.apache.maven.plugins</groupId>
>>>>> <artifactId>maven-surefire-plugin</artifactId>
>>>>> <version>${maven-surefire-plugin.version}</version>
>>>>> <configuration>
>>>>> <skipTests>true</skipTests>
>>>>> </configuration>
>>>>> </plugin>
>>>>>
>>>>> <plugin>
>>>>> <groupId>org.apache.maven.plugins</groupId>
>>>>> <artifactId>maven-clean-plugin</artifactId>
>>>>> <version>${maven-clean-plugin.version}</version>
>>>>> <configuration>
>>>>> <filesets>
>>>>> <fileset>
>>>>> <directory>reports</directory>
>>>>> </fileset>
>>>>> </filesets>
>>>>> </configuration>
>>>>> </plugin>
>>>>>
>>>>> <plugin>
>>>>> <groupId>org.codehaus.mojo</groupId>
>>>>> <artifactId>exec-maven-plugin</artifactId>
>>>>> <version>${exec-maven-plugin.version}</version>
>>>>> <executions>
>>>>> <execution>
>>>>> <phase>test</phase>
>>>>> <goals>
>>>>> <goal>java</goal>
>>>>> </goals>
>>>>> <configuration>
>>>>> <classpathScope>test</classpathScope>
>>>>> <mainClass>cucumber.api.cli.Main</mainClass>
>>>>> <arguments>
>>>>> <argument>--plugin</argument>
>>>>> <argument>json:reports/junit.json</argument>
>>>>> <argument>--strict</argument>
>>>>> <argument>--glue</argument>
>>>>> <argument>target/test-classes</argument>
>>>>> <argument>target/test-classes/.</argument>
>>>>> <argument>--tags</argument>
>>>>> <argument>${tagArg}</argument>
>>>>> </arguments>
>>>>> </configuration>
>>>>> </execution>
>>>>> </executions>
>>>>> </plugin>
>>>>> </plugins>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Any help is highly appreciated.
>>>>>
>>>>> Thanks,
>>>>> Raz
>>>>>
>>>>> --
>>>>> 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 [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/geb-user/8b3558dd-f6b4-4307-9d15-bb0cedd6fcd4%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/geb-user/8b3558dd-f6b4-4307-9d15-bb0cedd6fcd4%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/geb-user/95a959bd-b54a-4d33-8445-6a30eede13db%40googlegroups.com
>>> <https://groups.google.com/d/msgid/geb-user/95a959bd-b54a-4d33-8445-6a30eede13db%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/14fca32f-3bd5-4909-ab12-b25161c2c6bf%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/14fca32f-3bd5-4909-ab12-b25161c2c6bf%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/geb-user/CA%2B52dQR4O84u5NRMc0ZghdtLswm0mNw2YBAw_8Q_wpoqV2RuLw%40mail.gmail.com.