Geb groovy simple setup, getting NoClassDefFoundError
I am learning Geb (and Groovy) from a Java background and it seems to me that I understand how Geb works, but I cannot even get the most basic configuration. Basically, I am getting the following error:
Caught: java.lang.NoClassDefFoundError: geb / error / GebException
java.lang.NoClassDefFoundError: geb / error / GebException
on DriveIt.run (DriveIt.groovy: 15)
Called: 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 am using Eclipse, I have the jb jar correctly imported into the classpath. I don't seem to be doing anything wrong, but for the life of me I can’t figure out why I am getting the error "Browser" is not recognized.
Any help ??? you are welcome!!
source to share
You need to use it @Grab
as annotation to work. See: http://groovy.codehaus.org/Grape .
Alternatively, you might want to consider this sample project to learn how to use Geb with Gradle - using a build system to solve your problem, dependencies may be most reasonable in the long run.
source to share