How do I actually make Geb work with Grails 2.3.11?

148 views Asked by At

Stumbled across Geb the other day. I'm on Grails 2.3.11. How do I actually install Geb correctly? I downloaded the jar files and included them but when I try to run my code I get ClassNotFoundException on org.openqa.selenium.WebDriverException

I'm using IntelliJ IDEA if that matters.

Libraries Libraries

Gebtest.groovy

package gebish
import geb.Browser
class Gebtest {
    public static void main(String[] args) {
        println "Hi!"
        Browser.drive {
            go "http://gebish.org"

            assert title == "Geb - Very Groovy Browser Automation"
        }
    }
}

Errors

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:344)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:62)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:62)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:159)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at gebish.Gebtest.main(Gebtest.groovy:6)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriverException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 11 more
1

There are 1 answers

0
wwwclaes On

I also use Grails 2.3.11 and got GEB running. It's been a while, so I'm not sure what exactly is needed but here are some parts of my BuildConfig.groovy that might be relevant:

def gebVersion = "0.13.1"
def webdriverVersion = "2.53.1"

dependencies {
  compile "org.codehaus.groovy:groovy-backports-compat23:2.4.13"
  test "org.gebish:geb-spock:${gebVersion}"
  test "org.seleniumhq.selenium:selenium-support:${webdriverVersion}"
  test "org.seleniumhq.selenium:selenium-chrome-driver:${webdriverVersion}"
  test "org.seleniumhq.selenium:selenium-firefox-driver:${webdriverVersion}"
  test "org.seleniumhq.selenium:selenium-ie-driver:${webdriverVersion}"

  test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
}

plugins {
    test(":spock:0.7") {
        exclude "spock-grails-support"
    }
    test "org.grails.plugins:geb:${gebVersion}"
}