GroovyMN / gum-website

Groovy Users of Minnesota
http://groovy.mn
6 stars 10 forks source link

Geb tests no longer running under Grails 2.3 #127

Closed staticnull closed 10 years ago

staticnull commented 10 years ago

Spock tests are running without errors now under 2.3 but the Geb tests don't run (not in the report). I'm thinking we may need a different version of the plugin + the correct corresponding version of selenium.

staticnull commented 10 years ago

Just documenting my steps when I last tried to update the Grails app to a new version of GEB.

(1) http://grails.org/plugin/geb This plugin does not work with Grails 2.3.0. Version 0.9.2 and later of this plugin are compatible with Grails 2.3.1 and later. ... An example application with spock tests exists here Geb-example-grails. Grab it for reference and also make sure to check out the BuildConfig.

(2) Tried to follow what Luke Daley had in "Geb-example-grails" https://github.com/geb/geb-example-grails.

def gebVersion = "0.9.2"
def seleniumVersion = "2.32.0"

When I tired this the default HtmlUnitDriver started throwing errors. Luke's example only has a ChromeDriver and a FirefoxDriver.

| Running 2 spock tests... 1 of 2 | Failure: can get to archive(PagesSpec) | geb.driver.DriverCreationException: failed to create driver from callback 'script1407174395123715156723$_run_closure1@39f1879b' at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35) at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80) at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30) at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79) at geb.Configuration.createDriver(Configuration.groovy:354) at geb.Configuration.getDriver(Configuration.groovy:343) at geb.Browser.getDriver(Browser.groovy:105) at geb.Browser.go(Browser.groovy:394) at geb.Page.to(Page.groovy:184) at geb.Browser.via(Browser.groovy:475) at geb.Browser.to(Browser.groovy:434) at geb.Browser.to(Browser.groovy:412) at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51) at PagesSpec.can get to archive(PagesSpec.groovy:9) Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:171) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:171) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2532) at java.lang.Class.getDeclaredConstructors(Class.java:1901) at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) at script1407174395123715156723.run_closure1(script1407174395123715156723.groovy:14) at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29) ... 13 more Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 39 more

Thought I may have been running into the following issue with the resources plugin and GEB.

http://stackoverflow.com/questions/21441852/geb-tests-for-pages-with-javascript-in-grails-2-3-5

So I tried the following in Config.groovy

environments { ... test { grails.resources.mappers.hashandcache.excludes = ['*/'] } ... }

Tomas Lin thinks you should not use HTMLUnitDriver. :) http://markmail.org/message/lipwhyjunxczy3xz#query:+page:1+mid:lcuu2lcktsu5oxv7+state:results

(3) Tried to upgrade to the most recent version of the plugin. Following this page: http://www.gebish.org/manual/current/build-integrations.html#grails

def gebVersion = "0.9.3" def seleniumVersion = "2.41.0"

Got the following error:

| Failure: can get to archive(PagesSpec) | geb.driver.DriverCreationException: failed to create driver from callback 'script1407174588750715156723$_run_closure1@6c7f4ef6' at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35) at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:85) at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32) at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84) at geb.Configuration.createDriver(Configuration.groovy:361) at geb.Configuration.getDriver(Configuration.groovy:350) at geb.Browser.getDriver(Browser.groovy:105) at geb.Browser.go(Browser.groovy:405) at geb.Page.to(Page.groovy:195) at geb.Browser.via(Browser.groovy:488) at geb.Browser.to(Browser.groovy:448) at geb.Browser.to(Browser.groovy:426) at geb.spock.GebSpec.methodMissing(GebSpec.groovy:54) at PagesSpec.can get to archive(PagesSpec.groovy:9) ... Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 39 more

staticnull commented 10 years ago

We could just trying removing HTMLUnitDriver and go straight Chrome/Firefox and use code from here to make it easier for someone new to the project.

http://fbflex.wordpress.com/2013/01/06/geb-quickie-automatically-download-drivers-for-chrome-and-internet-explorer/

http://stackoverflow.com/questions/10995314/driver-executable-must-be-set-by-the-webdriver-ie-driver-system-property

staticnull commented 10 years ago

Created geb-upgrade branch with the above changes.

staticnull commented 10 years ago

Fixed by - http://github.com/GroovyMN/gum-website/pull/131