2

I'm learning Geb (and Groovy) coming from a Java background, and I feel like I understand how Geb works, but I'm failing to even get the simplest configuration working.
Basically, I'm getting the following error:

Caught: java.lang.NoClassDefFoundError: geb/error/GebException
java.lang.NoClassDefFoundError: geb/error/GebException
at DriveIt.run(DriveIt.groovy:15)
Caused by: java.lang.ClassNotFoundException: geb.error.GebException
... 1 more

My class is very simple:

    import groovy.grape.Grape  
    // I have these out of desperation  
    Grape.grab(group:"org.gebish", module:"geb-core", version:"0.9.3")
    Grape.grab(group:"org.seleniumhq.selenium", module:"selenium-firefox-driver", version:"2.41.0")
    Grape.grab(group:"org.seleniumhq.selenium", module:"selenium-support", version:"2.41.0")

// basic imports here
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.*;
    import geb.Browser;

    Browser.drive {
        go "http://www.google.com"   
    }

With this simple code i get an error on the "Browser.drive" line.

This is what my GebConfig.groovy file looks like:

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

driver = {
    def driver = new ChromeDriver()
    driver
}

baseUrl = 'http://localhost:8080/'
reportsDir = 'target/geb-reports'

And one more note, I'm using Eclipse, I do have the geb-code jar correctly imported in the classpath as well.
I don't seem to be doing anything incorrectly, but for the life of me, I can't figure out why I get an error saying "Browser" not recognized.

Any help??? please!!

xubean
  • 21
  • 3

3 Answers3

0

You can download needed package via command line by using command grape install org.gebish geb-core 0.9.3.

olyv
  • 3,699
  • 5
  • 37
  • 67
  • Thanks for answering. I'll go home and try this out. So, you're saying that importing and using grape is not enough? – xubean Sep 10 '14 at 21:15
  • Hello again, that didn't do anything. Not really sure what the 'grape' command is. i don't think there's any other way to install geb-core through terminal either. btw, i am on a unix environment (mac os). – xubean Sep 10 '14 at 22:11
  • Well, it can't find Browser class. Did you check if you have geb-core-0.9.3 under `%user%/.groovy\grapes\org.gebish\geb-core\jars` directory? – olyv Sep 11 '14 at 06:44
0

You'll need to use @Grab as an annotation for it work. See: http://groovy.codehaus.org/Grape.

Also, you might consider looking at this example project to learn how to use Geb with Gradle - using a build system to resolve your dependencies might be the most sensible thing in the long term.

erdi
  • 6,944
  • 18
  • 28
0

For some reason, none of the solutions really worked. I instead recreated an new Groovy project using Maven, which automatically downloaded all the dependencies. I then added the geb-core 0.9.3 dependency, which finally fixed it.

xubean
  • 21
  • 3