Search code examples
seleniumgroovynoclassdeffounderrorgeb

Groovy code: which library to import


import geb.Browser
import org.openqa.selenium.firefox.FirefoxDriver

Browser.drive {
    go "google.com"
}

I run the script above and get the following error:java.lang.NoClassDefFoundError: org/openqa/selenium/TakesScreenshot


Solution

  • As it says on the documentation page (and in it's maven info), you need:

    org.codehaus.geb:geb-implicit-assertions:0.7.2
    org.seleniumhq.selenium:selenium-api:2.15.0
    org.seleniumhq.selenium:selenium-support:2.15.0
    

    selenium-api depends on google guava

    and selenium-support depends on junit and hamcrest

    You'll also need to add groovy to the classpath as geb uses it under the covers