Quantcast

Issues with the grails-functional-test plugin

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Issues with the grails-functional-test plugin

mraible
Hello all,

I'm trying to right functional tests for my app to prove all the features are implemented as expected. It seems like the grails-functional-test plugin is the recommended way to do this.

https://github.com/Grailsrocks/grails-functional-test

Please correct me if I'm wrong.

With the latest release, I get the following error:

|  groovy.lang.MissingPropertyException: No such property: source for class: com.grailsrocks.functionaltest.client.ContentChangedEvent
        at com.grailsrocks.functionaltest.FunctionalTestException$_dumpURLStack_closure1.doCall(FunctionalTestException.groovy:39)
        at com.grailsrocks.functionaltest.FunctionalTestException.dumpURLStack(FunctionalTestException.groovy:38)
        at com.grailsrocks.functionaltest.FunctionalTestException.printStackTrace(FunctionalTestException.groovy:59)
| Completed 1 functional test, 1 failed in 3293ms

I'm using Grails 2.0.4. To get past this, I tried upgrading to the latest release on GitHub. With the latest release, the command to run it changed from "grails test-app -functional" to "grails functional-tests".  Now I get the following error:

| Error Error executing script FunctionalTests: Run (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: Run
        at java_lang_ClassLoader$loadClass.call(Unknown Source)
        at grails.util.BuildSettings$1.doCall(BuildSettings.groovy:336)
        at FunctionalTests.run(FunctionalTests:60)
        at FunctionalTests$run.call(Unknown Source)
        at gant.Gant.prepareTargets(Gant.groovy:607)
| Error Error executing script FunctionalTests: Run

Also, it seems like my functional tests are run when I use "grails test-app". This seems to happen to others as noted in this thread:

http://grails.1312388.n4.nabble.com/test-app-tries-to-run-functional-test-when-there-are-none-td4629579.html

Does anyone a workaround for these issues? If not, what's the recommended solution for functional testing with Grails?

Thanks,

Matt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

smaldini
I'm not sure about the recommended way but there is a large consensus around Geb for functional testing (http://grails.org/plugin/geb). Coupled to Spock, you have nice readable tests like :

That's said, are you using the github version, or the grails repo version ? I'm not sure Marc has deployed his very latest changes on grails repo. Sorry for the bad experience you get with the plugin, some of them requires work to migrate to grails 2 and I'm not sure if in this case a new version has been deployed.

On Sat, Jun 9, 2012 at 10:45 PM, mraible <[hidden email]> wrote:
Hello all,

I'm trying to right functional tests for my app to prove all the features
are implemented as expected. It seems like the grails-functional-test plugin
is the recommended way to do this.

https://github.com/Grailsrocks/grails-functional-test

Please correct me if I'm wrong.

With the latest release, I get the following error:

|  groovy.lang.MissingPropertyException: No such property: source for class:
com.grailsrocks.functionaltest.client.ContentChangedEvent
       at
com.grailsrocks.functionaltest.FunctionalTestException$_dumpURLStack_closure1.doCall(FunctionalTestException.groovy:39)
       at
com.grailsrocks.functionaltest.FunctionalTestException.dumpURLStack(FunctionalTestException.groovy:38)
       at
com.grailsrocks.functionaltest.FunctionalTestException.printStackTrace(FunctionalTestException.groovy:59)
| Completed 1 functional test, 1 failed in 3293ms

I'm using Grails 2.0.4. To get past this, I tried upgrading to the latest
release on GitHub. With the latest release, the command to run it changed
from "grails test-app -functional" to "grails functional-tests".  Now I get
the following error:

| Error Error executing script FunctionalTests: Run (NOTE: Stack trace has
been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: Run
       at java_lang_ClassLoader$loadClass.call(Unknown Source)
       at grails.util.BuildSettings$1.doCall(BuildSettings.groovy:336)
       at FunctionalTests.run(FunctionalTests:60)
       at FunctionalTests$run.call(Unknown Source)
       at gant.Gant.prepareTargets(Gant.groovy:607)
| Error Error executing script FunctionalTests: Run

Also, it seems like my functional tests are run when I use "grails
test-app". This seems to happen to others as noted in this thread:

http://grails.1312388.n4.nabble.com/test-app-tries-to-run-functional-test-when-there-are-none-td4629579.html

Does anyone a workaround for these issues? If not, what's the recommended
solution for functional testing with Grails?

Thanks,

Matt


--
View this message in context: http://grails.1312388.n4.nabble.com/Issues-with-the-grails-functional-test-plugin-tp4629845.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Stéphane MALDINI
--


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

bksaville
I honestly have never had luck with the functional-test plugin.  If you are using spock and do not want to use geb (ie testing a REST API, etc), you can use the spock functional plugin -  http://grails.org/plugin/functional-spock.

-Brian

On Sun, Jun 10, 2012 at 2:17 AM, Stephane Maldini <[hidden email]> wrote:
I'm not sure about the recommended way but there is a large consensus around Geb for functional testing (http://grails.org/plugin/geb). Coupled to Spock, you have nice readable tests like :

That's said, are you using the github version, or the grails repo version ? I'm not sure Marc has deployed his very latest changes on grails repo. Sorry for the bad experience you get with the plugin, some of them requires work to migrate to grails 2 and I'm not sure if in this case a new version has been deployed.


On Sat, Jun 9, 2012 at 10:45 PM, mraible <[hidden email]> wrote:
Hello all,

I'm trying to right functional tests for my app to prove all the features
are implemented as expected. It seems like the grails-functional-test plugin
is the recommended way to do this.

https://github.com/Grailsrocks/grails-functional-test

Please correct me if I'm wrong.

With the latest release, I get the following error:

|  groovy.lang.MissingPropertyException: No such property: source for class:
com.grailsrocks.functionaltest.client.ContentChangedEvent
       at
com.grailsrocks.functionaltest.FunctionalTestException$_dumpURLStack_closure1.doCall(FunctionalTestException.groovy:39)
       at
com.grailsrocks.functionaltest.FunctionalTestException.dumpURLStack(FunctionalTestException.groovy:38)
       at
com.grailsrocks.functionaltest.FunctionalTestException.printStackTrace(FunctionalTestException.groovy:59)
| Completed 1 functional test, 1 failed in 3293ms

I'm using Grails 2.0.4. To get past this, I tried upgrading to the latest
release on GitHub. With the latest release, the command to run it changed
from "grails test-app -functional" to "grails functional-tests".  Now I get
the following error:

| Error Error executing script FunctionalTests: Run (NOTE: Stack trace has
been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: Run
       at java_lang_ClassLoader$loadClass.call(Unknown Source)
       at grails.util.BuildSettings$1.doCall(BuildSettings.groovy:336)
       at FunctionalTests.run(FunctionalTests:60)
       at FunctionalTests$run.call(Unknown Source)
       at gant.Gant.prepareTargets(Gant.groovy:607)
| Error Error executing script FunctionalTests: Run

Also, it seems like my functional tests are run when I use "grails
test-app". This seems to happen to others as noted in this thread:

http://grails.1312388.n4.nabble.com/test-app-tries-to-run-functional-test-when-there-are-none-td4629579.html

Does anyone a workaround for these issues? If not, what's the recommended
solution for functional testing with Grails?

Thanks,

Matt


--
View this message in context: http://grails.1312388.n4.nabble.com/Issues-with-the-grails-functional-test-plugin-tp4629845.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Stéphane MALDINI
--



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

mraible
In reply to this post by smaldini
Thanks for the reply. I tried both the github version and the grails repo one. Both had issues.

Thanks for the tip on the Geb plugin. I've tried that and it seems to work pretty well. However, I've run into an issue with trying to test signup for a new user. I have the Spring Security UI Plugin installed and it always seems to fail on the last step after verifying the registration code. 

Here's my test:

    def "signup as a new user"() {
        given:
        def server = SimpleSmtpServer.start(1025)

        when:
        to SignupPage
        form.username = "[hidden email]"
        form.email = "[hidden email]"
        form.password = "IloveGROOVY@2"
        form.password2 = "IloveGROOVY@2"
        createAccountButton.click()

        then:
        $('form').text().contains("Your account registration email was sent")
        server.receivedEmailSize == 1
        def email = server.receivedEmail.next()
        String body = email.body
        int index = body.indexOf('/register/verifyRegistration?t=')
        index > -1
        int index2 = body.indexOf('"', index + 1)
        String code = body.substring(index + '/register/verifyRegistration?t='.length(), index2)
        code != null

        when:
        go '/register/verifyRegistration?t=' + code

        then:
        waitFor { title ==~ /Welcome to Happy Trails!.+/ }
        userIcon.parent().contains("[hidden email]")
    }

The error:

| Failure:  signup as a new user(happytrails.AuthenticatedUserSpec)
|  geb.waiting.WaitTimeoutException: condition did not pass in 5.0 seconds (failed with exception)
        at geb.waiting.Wait.waitFor(Wait.groovy:128)
        at geb.waiting.WaitingSupport.doWaitFor(WaitingSupport.groovy:108)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:66)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:62)
        at geb.Browser.methodMissing(Browser.groovy:168)
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
        at org.spockframework.util.GroovyRuntimeUtil.invokeMethod(GroovyRuntimeUtil.java:100)
        at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:47)
Caused by: Assertion failed: 

title ==~ /Welcome to Happy Trails!.+/
|     |
null  false

        at happytrails.AuthenticatedUserSpec.signup as a new user_closure1(AuthenticatedUserSpec.groovy:47)
        at geb.waiting.Wait.waitFor(Wait.groovy:117)
        ... 7 more

If I look at the HTML page being generated, it has "-- no page source --" in it.

Is there anyway to tell Geb to follow redirects? I've gone through everything manually and it works fine in a real browser.

Thanks,

Matt

On Jun 10, 2012, at 2:22 AM, smaldini [via Grails] wrote:

I'm not sure about the recommended way but there is a large consensus around Geb for functional testing (http://grails.org/plugin/geb). Coupled to Spock, you have nice readable tests like :

That's said, are you using the github version, or the grails repo version ? I'm not sure Marc has deployed his very latest changes on grails repo. Sorry for the bad experience you get with the plugin, some of them requires work to migrate to grails 2 and I'm not sure if in this case a new version has been deployed.

On Sat, Jun 9, 2012 at 10:45 PM, mraible <<a href="x-msg://5/user/SendEmail.jtp?type=node&amp;node=4629848&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> wrote:
Hello all,

I'm trying to right functional tests for my app to prove all the features
are implemented as expected. It seems like the grails-functional-test plugin
is the recommended way to do this.

https://github.com/Grailsrocks/grails-functional-test

Please correct me if I'm wrong.

With the latest release, I get the following error:

|  groovy.lang.MissingPropertyException: No such property: source for class:
com.grailsrocks.functionaltest.client.ContentChangedEvent
       at
com.grailsrocks.functionaltest.FunctionalTestException$_dumpURLStack_closure1.doCall(FunctionalTestException.groovy:39)
       at
com.grailsrocks.functionaltest.FunctionalTestException.dumpURLStack(FunctionalTestException.groovy:38)
       at
com.grailsrocks.functionaltest.FunctionalTestException.printStackTrace(FunctionalTestException.groovy:59)
| Completed 1 functional test, 1 failed in 3293ms

I'm using Grails 2.0.4. To get past this, I tried upgrading to the latest
release on GitHub. With the latest release, the command to run it changed
from "grails test-app -functional" to "grails functional-tests".  Now I get
the following error:

| Error Error executing script FunctionalTests: Run (NOTE: Stack trace has
been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: Run
       at java_lang_ClassLoader$loadClass.call(Unknown Source)
       at grails.util.BuildSettings$1.doCall(BuildSettings.groovy:336)
       at FunctionalTests.run(FunctionalTests:60)
       at FunctionalTests$run.call(Unknown Source)
       at gant.Gant.prepareTargets(Gant.groovy:607)
| Error Error executing script FunctionalTests: Run

Also, it seems like my functional tests are run when I use "grails
test-app". This seems to happen to others as noted in this thread:

http://grails.1312388.n4.nabble.com/test-app-tries-to-run-functional-test-when-there-are-none-td4629579.html

Does anyone a workaround for these issues? If not, what's the recommended
solution for functional testing with Grails?

Thanks,

Matt


--
View this message in context: http://grails.1312388.n4.nabble.com/Issues-with-the-grails-functional-test-plugin-tp4629845.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Stéphane MALDINI
--





If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/Issues-with-the-grails-functional-test-plugin-tp4629845p4629848.html
To unsubscribe from Issues with the grails-functional-test plugin, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

Marc Palmer Local
In reply to this post by mraible

On 9 Jun 2012, at 22:45, mraible wrote:

> Hello all,
>
> I'm trying to right functional tests for my app to prove all the features
> are implemented as expected. It seems like the grails-functional-test plugin
> is the recommended way to do this.
>
> https://github.com/Grailsrocks/grails-functional-test
>
> Please correct me if I'm wrong.


Hi Matt,

Sorry about that. It was a typo in some output that only occurs in an error.

By latest build do you mean the last release of the plugin, or have you built from master.

I believe I fixed and released this the other day as a snapshot.

So, if you're not using version 2.0.M3-SNAPSHOT, please give that one a go.

Marc

~ ~ ~
Marc Palmer
Freelancer (Grails/Groovy/Java/UX)

I offer commercial support for Grails plugins from as low as $50/mo.
For details see: http://grailsrocks.com

Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc
Contributor @ http://grails.org |  Founder @ http://noticelocal.com
Developer @ http://weceem.org | Member @ http://spottymushroom.com
Twitter: http://twitter.com/wangjammer5 


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

Marc Palmer Local
In reply to this post by bksaville

On 10 Jun 2012, at 15:27, Brian Saville wrote:

> I honestly have never had luck with the functional-test plugin.  If you are using spock and do not want to use geb (ie testing a REST API, etc), you can use the spock functional plugin -  http://grails.org/plugin/functional-spock.

Certainly Spock, Geb etc all great.

Functional-test had a long period where it wouldn't work well with newer Grails build (1.3 onwards).

The 2.0 snapshots resolve these problems, and introduce API testing as well as "fake browser" testing.

Sadly any "fake browser" testing that uses HtmlUnit (including functional test and others using WebDriver that use the HtmlUnit mode) seem pretty doomed for newer jQuery versions, and to my knowledge there does not seem to be any movement on this.

The upshot is that currently we can't functional test our apps with htmlunit, but we do functional test our APIs using the new APITestCase base class in functional-test 2.0 - "but look ma, no docs" :(

Marc
~ ~ ~
Marc Palmer
Freelancer (Grails/Groovy/Java/UX)

I offer commercial support for Grails plugins from as low as $50/mo.
For details see: http://grailsrocks.com

Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc
Contributor @ http://grails.org |  Founder @ http://noticelocal.com
Developer @ http://weceem.org | Member @ http://spottymushroom.com
Twitter: http://twitter.com/wangjammer5 


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

ld@ldaley.com
In reply to this post by mraible

On 11/06/2012, at 8:19 AM, mraible wrote:

Thanks for the reply. I tried both the github version and the grails repo one. Both had issues.

Thanks for the tip on the Geb plugin. I've tried that and it seems to work pretty well. However, I've run into an issue with trying to test signup for a new user. I have the Spring Security UI Plugin installed and it always seems to fail on the last step after verifying the registration code. 

Here's my test:

    def "signup as a new user"() {
        given:
        def server = SimpleSmtpServer.start(1025)

        when:
        to SignupPage
        form.username = "<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]"
        form.email = "<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=1" target="_top" rel="nofollow" link="external">[hidden email]"
        form.password = "IloveGROOVY@2"
        form.password2 = "IloveGROOVY@2"
        createAccountButton.click()

        then:
        $('form').text().contains("Your account registration email was sent")
        server.receivedEmailSize == 1
        def email = server.receivedEmail.next()
        String body = email.body
        int index = body.indexOf('/register/verifyRegistration?t=')
        index > -1
        int index2 = body.indexOf('"', index + 1)
        String code = body.substring(index + '/register/verifyRegistration?t='.length(), index2)
        code != null

        when:
        go '/register/verifyRegistration?t=' + code

        then:
        waitFor { title ==~ /Welcome to Happy Trails!.+/ }
        userIcon.parent().contains("<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=2" target="_top" rel="nofollow" link="external">[hidden email]")
    }

The error:

| Failure:  signup as a new user(happytrails.AuthenticatedUserSpec)
|  geb.waiting.WaitTimeoutException: condition did not pass in 5.0 seconds (failed with exception)
        at geb.waiting.Wait.waitFor(Wait.groovy:128)
        at geb.waiting.WaitingSupport.doWaitFor(WaitingSupport.groovy:108)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:66)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:62)
        at geb.Browser.methodMissing(Browser.groovy:168)
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
        at org.spockframework.util.GroovyRuntimeUtil.invokeMethod(GroovyRuntimeUtil.java:100)
        at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:47)
Caused by: Assertion failed: 

title ==~ /Welcome to Happy Trails!.+/
|     |
null  false

        at happytrails.AuthenticatedUserSpec.signup as a new user_closure1(AuthenticatedUserSpec.groovy:47)
        at geb.waiting.Wait.waitFor(Wait.groovy:117)
        ... 7 more

If I look at the HTML page being generated, it has "-- no page source --" in it.

Is there anyway to tell Geb to follow redirects? I've gone through everything manually and it works fine in a real browser.

It should by default. Are you using the HTMLUnit driver? I'd strongly recommend not doing that as its JavaScript support is not very good. However, I can't see how that would be in play here.

What's URL is the browser at before the failed verification? You can get it with `driver.currentUrl`.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

mraible

On Jun 11, 2012, at 9:07 AM, [hidden email] [via Grails] wrote:


On 11/06/2012, at 8:19 AM, mraible wrote:

Thanks for the reply. I tried both the github version and the grails repo one. Both had issues.

Thanks for the tip on the Geb plugin. I've tried that and it seems to work pretty well. However, I've run into an issue with trying to test signup for a new user. I have the Spring Security UI Plugin installed and it always seems to fail on the last step after verifying the registration code. 

Here's my test:

    def "signup as a new user"() {
        given:
        def server = SimpleSmtpServer.start(1025)

        when:
        to SignupPage
        form.username = "<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]"
        form.email = "<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=1" target="_top" rel="nofollow" link="external">[hidden email]"
        form.password = "IloveGROOVY@2"
        form.password2 = "IloveGROOVY@2"
        createAccountButton.click()

        then:
        $('form').text().contains("Your account registration email was sent")
        server.receivedEmailSize == 1
        def email = server.receivedEmail.next()
        String body = email.body
        int index = body.indexOf('/register/verifyRegistration?t=')
        index > -1
        int index2 = body.indexOf('"', index + 1)
        String code = body.substring(index + '/register/verifyRegistration?t='.length(), index2)
        code != null

        when:
        go '/register/verifyRegistration?t=' + code

        then:
        waitFor { title ==~ /Welcome to Happy Trails!.+/ }
        userIcon.parent().contains("<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=2" target="_top" rel="nofollow" link="external">[hidden email]")
    }

The error:

| Failure:  signup as a new user(happytrails.AuthenticatedUserSpec)
|  geb.waiting.WaitTimeoutException: condition did not pass in 5.0 seconds (failed with exception)
        at geb.waiting.Wait.waitFor(Wait.groovy:128)
        at geb.waiting.WaitingSupport.doWaitFor(WaitingSupport.groovy:108)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:66)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:62)
        at geb.Browser.methodMissing(Browser.groovy:168)
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
        at org.spockframework.util.GroovyRuntimeUtil.invokeMethod(GroovyRuntimeUtil.java:100)
        at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:47)
Caused by: Assertion failed: 

title ==~ /Welcome to Happy Trails!.+/
|     |
null  false

        at happytrails.AuthenticatedUserSpec.signup as a new user_closure1(AuthenticatedUserSpec.groovy:47)
        at geb.waiting.Wait.waitFor(Wait.groovy:117)
        ... 7 more

If I look at the HTML page being generated, it has "-- no page source --" in it.

Is there anyway to tell Geb to follow redirects? I've gone through everything manually and it works fine in a real browser.

It should by default. Are you using the HTMLUnit driver? I'd strongly recommend not doing that as its JavaScript support is not very good. However, I can't see how that would be in play here.

What's URL is the browser at before the failed verification? You can get it with `driver.currentUrl`.

Yes, I'm using the HtmlUnit driver. Here's my GebConfig.groovy:

package happytrails

import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.chrome.ChromeDriver

driver = { 
def driver = new HtmlUnitDriver()
driver.javascriptEnabled = true
driver
}

environments {
chrome {
driver = { new ChromeDriver() }
}

firefox {
driver = { new FirefoxDriver() }
}
}

If I print the URL before the failed verification, it seems to be correct, but maybe it's not actually retrieved?

        when:
        go '/register/verifyRegistration', t: code

        then:
        println driver.currentUrl

Here's what's printed:


If I try to use the FirefoxDriver instead, I get:

java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/xml/namespace/QName"
at javax.xml.xpath.XPathConstants.<clinit>(XPathConstants.java:53)
at org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:121)
at org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:61)
at org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:64)
at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:466)
at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:444)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:74)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:200)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:85)
at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:24)


With Chrome, it seems like I'm supposed to execute the following, but no tests are run.

 grails test-app -Dwebdriver.chrome.driver="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

ld@ldaley.com

On 11/06/2012, at 6:38 PM, mraible wrote:


On Jun 11, 2012, at 9:07 AM, <a href="x-msg://567/user/SendEmail.jtp?type=node&amp;node=4629923&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email] [via Grails] wrote:


On 11/06/2012, at 8:19 AM, mraible wrote:

Thanks for the reply. I tried both the github version and the grails repo one. Both had issues.

Thanks for the tip on the Geb plugin. I've tried that and it seems to work pretty well. However, I've run into an issue with trying to test signup for a new user. I have the Spring Security UI Plugin installed and it always seems to fail on the last step after verifying the registration code. 

Here's my test:

    def "signup as a new user"() {
        given:
        def server = SimpleSmtpServer.start(1025)

        when:
        to SignupPage
        form.username = "<a href="<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=0"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]"
        form.email = "<a href="<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=1"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=1" target="_top" rel="nofollow" link="external">[hidden email]"
        form.password = "IloveGROOVY@2"
        form.password2 = "IloveGROOVY@2"
        createAccountButton.click()

        then:
        $('form').text().contains("Your account registration email was sent")
        server.receivedEmailSize == 1
        def email = server.receivedEmail.next()
        String body = email.body
        int index = body.indexOf('/register/verifyRegistration?t=')
        index > -1
        int index2 = body.indexOf('"', index + 1)
        String code = body.substring(index + '/register/verifyRegistration?t='.length(), index2)
        code != null

        when:
        go '/register/verifyRegistration?t=' + code

        then:
        waitFor { title ==~ /Welcome to Happy Trails!.+/ }
        userIcon.parent().contains("<a href="<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=2"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=2" target="_top" rel="nofollow" link="external">[hidden email]")
    }

The error:

| Failure:  signup as a new user(happytrails.AuthenticatedUserSpec)
|  geb.waiting.WaitTimeoutException: condition did not pass in 5.0 seconds (failed with exception)
        at geb.waiting.Wait.waitFor(Wait.groovy:128)
        at geb.waiting.WaitingSupport.doWaitFor(WaitingSupport.groovy:108)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:66)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:62)
        at geb.Browser.methodMissing(Browser.groovy:168)
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
        at org.spockframework.util.GroovyRuntimeUtil.invokeMethod(GroovyRuntimeUtil.java:100)
        at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:47)
Caused by: Assertion failed: 

title ==~ /Welcome to Happy Trails!.+/
|     |
null  false

        at happytrails.AuthenticatedUserSpec.signup as a new user_closure1(AuthenticatedUserSpec.groovy:47)
        at geb.waiting.Wait.waitFor(Wait.groovy:117)
        ... 7 more

If I look at the HTML page being generated, it has "-- no page source --" in it.

Is there anyway to tell Geb to follow redirects? I've gone through everything manually and it works fine in a real browser.

It should by default. Are you using the HTMLUnit driver? I'd strongly recommend not doing that as its JavaScript support is not very good. However, I can't see how that would be in play here.

What's URL is the browser at before the failed verification? You can get it with `driver.currentUrl`.

Yes, I'm using the HtmlUnit driver. Here's my GebConfig.groovy:

package happytrails

import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.chrome.ChromeDriver

driver = { 
def driver = new HtmlUnitDriver()
driver.javascriptEnabled = true
driver
}

environments {
chrome {
driver = { new ChromeDriver() }
}

firefox {
driver = { new FirefoxDriver() }
}
}

If I print the URL before the failed verification, it seems to be correct, but maybe it's not actually retrieved?

I can't recall what happens if the page is plain text. I know at the least that HTMLUnit is prone to freaking out in this case. I would expect the server to be return HTML here though, and regardless the driver should be seeing the 30x.

Exactly why I avoid HTMLUnit TBH. Weird stuff like this is too hard to debug.


        when:
        go '/register/verifyRegistration', t: code

        then:
        println driver.currentUrl

Here's what's printed:


If I try to use the FirefoxDriver instead, I get:

java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/xml/namespace/QName"
at javax.xml.xpath.XPathConstants.<clinit>(XPathConstants.java:53)
at org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:121)
at org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:61)
at org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:64)
at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:466)
at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:444)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:74)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:200)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:85)
at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:24)

I think this is the good old xml-apis fiasco. You've likely got some dependency dragging in xerces. That's speculation, but it's often the cause of this kind of thing.

With Chrome, it seems like I'm supposed to execute the following, but no tests are run.

 grails test-app -Dwebdriver.chrome.driver="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

I never have to do that. I just put the native chrome driver binary on my PATH. That's what “webdriver.chrome.driver” is supposed to point to, not chrome itself. See http://code.google.com/p/selenium/wiki/ChromeDriver




View this message in context: Re: Issues with the grails-functional-test plugin
Sent from the Grails - user mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

mraible

On Jun 11, 2012, at 11:54 AM, [hidden email] [via Grails] wrote:


On 11/06/2012, at 6:38 PM, mraible wrote:


On Jun 11, 2012, at 9:07 AM, <a href="<a href="x-msg://567/user/SendEmail.jtp?type=node&amp;amp;node=4629923&amp;amp;i=0">x-msg://567/user/SendEmail.jtp?type=node&amp;node=4629923&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email] [via Grails] wrote:


On 11/06/2012, at 8:19 AM, mraible wrote:

Thanks for the reply. I tried both the github version and the grails repo one. Both had issues.

Thanks for the tip on the Geb plugin. I've tried that and it seems to work pretty well. However, I've run into an issue with trying to test signup for a new user. I have the Spring Security UI Plugin installed and it always seems to fail on the last step after verifying the registration code. 

Here's my test:

    def "signup as a new user"() {
        given:
        def server = SimpleSmtpServer.start(1025)

        when:
        to SignupPage
        form.username = "<a href="<a href="<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;amp;node=4629860&amp;amp;amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=0"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=0"><a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=0"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=0">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]"
        form.email = "<a href="<a href="<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;amp;node=4629860&amp;amp;amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=1"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=1"><a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=1"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=1">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=1" target="_top" rel="nofollow" link="external">[hidden email]"
        form.password = "IloveGROOVY@2"
        form.password2 = "IloveGROOVY@2"
        createAccountButton.click()

        then:
        $('form').text().contains("Your account registration email was sent")
        server.receivedEmailSize == 1
        def email = server.receivedEmail.next()
        String body = email.body
        int index = body.indexOf('/register/verifyRegistration?t=')
        index > -1
        int index2 = body.indexOf('"', index + 1)
        String code = body.substring(index + '/register/verifyRegistration?t='.length(), index2)
        code != null

        when:
        go '/register/verifyRegistration?t=' + code

        then:
        waitFor { title ==~ /Welcome to Happy Trails!.+/ }
        userIcon.parent().contains("<a href="<a href="<a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;amp;node=4629860&amp;amp;amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=2"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=2"><a href="<a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;amp;node=4629860&amp;amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=2"><a href="x-msg://30/user/SendEmail.jtp?type=node&amp;amp;node=4629860&amp;amp;i=2">x-msg://30/user/SendEmail.jtp?type=node&amp;node=4629860&amp;i=2" target="_top" rel="nofollow" link="external">[hidden email]")
    }

The error:

| Failure:  signup as a new user(happytrails.AuthenticatedUserSpec)
|  geb.waiting.WaitTimeoutException: condition did not pass in 5.0 seconds (failed with exception)
        at geb.waiting.Wait.waitFor(Wait.groovy:128)
        at geb.waiting.WaitingSupport.doWaitFor(WaitingSupport.groovy:108)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:66)
        at geb.waiting.WaitingSupport.waitFor(WaitingSupport.groovy:62)
        at geb.Browser.methodMissing(Browser.groovy:168)
        at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
        at org.spockframework.util.GroovyRuntimeUtil.invokeMethod(GroovyRuntimeUtil.java:100)
        at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:47)
Caused by: Assertion failed: 

title ==~ /Welcome to Happy Trails!.+/
|     |
null  false

        at happytrails.AuthenticatedUserSpec.signup as a new user_closure1(AuthenticatedUserSpec.groovy:47)
        at geb.waiting.Wait.waitFor(Wait.groovy:117)
        ... 7 more

If I look at the HTML page being generated, it has "-- no page source --" in it.

Is there anyway to tell Geb to follow redirects? I've gone through everything manually and it works fine in a real browser.

It should by default. Are you using the HTMLUnit driver? I'd strongly recommend not doing that as its JavaScript support is not very good. However, I can't see how that would be in play here.

What's URL is the browser at before the failed verification? You can get it with `driver.currentUrl`.

Yes, I'm using the HtmlUnit driver. Here's my GebConfig.groovy:

package happytrails

import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.chrome.ChromeDriver

driver = { 
def driver = new HtmlUnitDriver()
driver.javascriptEnabled = true
driver
}

environments {
chrome {
driver = { new ChromeDriver() }
}

firefox {
driver = { new FirefoxDriver() }
}
}

If I print the URL before the failed verification, it seems to be correct, but maybe it's not actually retrieved?

I can't recall what happens if the page is plain text. I know at the least that HTMLUnit is prone to freaking out in this case. I would expect the server to be return HTML here though, and regardless the driver should be seeing the 30x.

Exactly why I avoid HTMLUnit TBH. Weird stuff like this is too hard to debug.


        when:
        go '/register/verifyRegistration', t: code

        then:
        println driver.currentUrl

Here's what's printed:


If I try to use the FirefoxDriver instead, I get:

java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/xml/namespace/QName"
at javax.xml.xpath.XPathConstants.<clinit>(XPathConstants.java:53)
at org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:121)
at org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:61)
at org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:64)
at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:466)
at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:444)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:74)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:200)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:85)
at happytrails.AuthenticatedUserSpec.signup as a new user(AuthenticatedUserSpec.groovy:24)

I think this is the good old xml-apis fiasco. You've likely got some dependency dragging in xerces. That's speculation, but it's often the cause of this kind of thing.

With Chrome, it seems like I'm supposed to execute the following, but no tests are run.

 grails test-app -Dwebdriver.chrome.driver="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

I never have to do that. I just put the native chrome driver binary on my PATH. That's what “webdriver.chrome.driver” is supposed to point to, not chrome itself. See http://code.google.com/p/selenium/wiki/ChromeDriver

Thanks for tip! I downloaded "chromedriver" and put it in my $GRAILS_HOME/bin directory. This helped me visualize what was happening and realize that the context path wasn't in the  URL I was requesting. Changing it to the following (no forward slash at the beginning) solved my problem:

go 'register/verifyRegistration', t: code

I appreciate the help!


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

antony
In reply to this post by mraible
Hi Matt,

I think the reason your test doesn't work is because you need to
create a Page object for your registration page, and then replace the
following line:

  go '/register/verifyRegistration?t=' + code

with

when:
    to RegisterPage, 'verifyRegistration', t: code
then:
    at RegisterPage

Your RegisterPage should look something like this:

class RegisterPage extends Page {

static url = 'register'

static at = {
     title ==~ /Welcome to Happy Trails!.+/
}

}

Cheers,
Antony

On 11 June 2012 08:19, mraible <[hidden email]> wrote:
>   go '/register/verifyRegistration?t=' + code



--
________________________________
ꜽ . antony jones . http://www.enzy.org

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Issues with the grails-functional-test plugin

antony
Sorry, a little late with my reply I now realise!

Regardless, you really should be using Page objects and Modules to
make your test code more focussed, as it will greatly increase your
ability to reuse test code, and get the full benefit of Geb+Spock.

Cheers,
Antony

On 12 June 2012 15:47, Antony Jones <[hidden email]> wrote:

> Hi Matt,
>
> I think the reason your test doesn't work is because you need to
> create a Page object for your registration page, and then replace the
> following line:
>
>  go '/register/verifyRegistration?t=' + code
>
> with
>
> when:
>    to RegisterPage, 'verifyRegistration', t: code
> then:
>    at RegisterPage
>
> Your RegisterPage should look something like this:
>
> class RegisterPage extends Page {
>
> static url = 'register'
>
> static at = {
>     title ==~ /Welcome to Happy Trails!.+/
> }
>
> }
>
> Cheers,
> Antony
>
> On 11 June 2012 08:19, mraible <[hidden email]> wrote:
>>   go '/register/verifyRegistration?t=' + code
>
>
>
> --
> ________________________________
> ꜽ . antony jones . http://www.enzy.org



--
________________________________
ꜽ . antony jones . http://www.enzy.org

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...