0

I'm new to Geb and trying to do a quick test to evaluate it before further use. Due to proxy permissions etc I would like to do so without using Grape. Therefore, I have attempted to download the required jars manually and am attempting to specify them on the command line.

However when doing so I receive the following class not found for WebDriverException:

C:\geb-test>groovy -cp geb-core-0.9.2.jar;selenium-htmlunit-driver-2.35.0.jar;selenium-support-2.35.0.jar GoogleTest
Caught: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
        at GoogleTest.run(GoogleTest.groovy:3)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriverException
        ... 1 more

C:\geb-test>

Do I require additional jars? If so which ones? I've tried a few others but with no joy - as I noted WebDriverException is in selenium-api-2.35.0.jar, but it made no difference.

So, here's the details starting with some version information:

  • Groovy Version: 2.1.7 JVM: 1.7.0_40 Vendor: Oracle Corporation OS: Windows 7

To start with, I'm using the simple geb inline scripting example which I've put in a file called GoogleTest.groovy:

import geb.Browser

Browser.drive {
    go "http://google.com/ncr"

    // make sure we actually got to the page
    assert title == "Google"

    // enter wikipedia into the search field
    $("input", name: "q").value("wikipedia")

    // wait for the change to results page to happen
    // (google updates the page dynamically without a new request)
    waitFor { title.endsWith("Google Search") }

    // is the first link to wikipedia?
    def firstLink = $("li.g", 0).find("a.l")
    assert firstLink.text() == "Wikipedia"

    // click the link 
    firstLink.click()

    // wait for Google's javascript to redirect to Wikipedia
    waitFor { title == "Wikipedia" }
}

Then based on the geb install instructions I made sure I had the jars mentioned in the @Grab annotations. This resulted in my test directory having the following files:

07/11/2013  10:46    <DIR>          .
07/11/2013  10:46    <DIR>          ..
06/11/2013  14:51           460,165 geb-core-0.9.2.jar
06/11/2013  15:13               711 GoogleTest.groovy
06/11/2013  14:55            56,189 selenium-htmlunit-driver-2.35.0.jar
06/11/2013  14:54           130,535 selenium-support-2.35.0.jar
               4 File(s)        647,600 bytes

And then for completeness, I attempt the above mentioned command line execution:

C:\geb-test>groovy -cp geb-core-0.9.2.jar;selenium-htmlunit-driver-2.35.0.jar;selenium-support-2.35.0.jar GoogleTest
Caught: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
        at GoogleTest.run(GoogleTest.groovy:3)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriverException
        ... 1 more

C:\geb-test>

I'm starting to wonder if the issue is multiple jars with Groovy '-cp' commandline. I'm now attempting to put the jars in the ${user.home}.groovy\lib directory. But then I end up with an not defined class for GebException. Maybe you have to use Grape to have any chance of getting this working. :/ Let me know.

I Stevenson
  • 854
  • 1
  • 7
  • 24

1 Answers1

1

Alright, well I gave in and decided to try and force proxy authentication to work.

I decided to try with the Chrome driver so my annotations looked like this:

@Grapes([
    @Grab("org.gebish:geb-core:0.9.2"),
    @Grab("org.seleniumhq.selenium:selenium-chrome-driver:2.26.0"),
    @Grab("org.seleniumhq.selenium:selenium-support:2.26.0")
])

End result, is that there is a significant dependency chain, so perhaps attempting manually is not advisable. If you do wish to do so, then prepare your class path with the below.

And going from an empty grape repository I ended up with this (shown with 'grape list'):

  • cglib cglib-nodep [2.1_3]
  • com.google.guava guava [13.0.1]
  • com.google.guava guava-parent [13.0.1]
  • commons-codec commons-codec [1.6]
  • commons-logging commons-logging [1.1.1]
  • net.java.dev.jna jna [3.4.0]
  • net.java.dev.jna platform [3.4.0]
  • org.apache apache [4, 7, 9]
  • org.apache.commons commons-exec [1.1]
  • org.apache.commons commons-parent [17, 22, 5]
  • org.apache.httpcomponents httpclient [4.2.1]
  • org.apache.httpcomponents httpcomponents-client [4.2.1]
  • org.apache.httpcomponents httpcomponents-core [4.2.1]
  • org.apache.httpcomponents httpcore [4.2.1]
  • org.apache.httpcomponents project [6]
  • org.gebish geb-ast [0.9.2]
  • org.gebish geb-core [0.9.2]
  • org.gebish geb-implicit-assertions [0.9.2]
  • org.gebish geb-waiting [0.9.2]
  • org.json json [20080701]
  • org.seleniumhq.selenium selenium-api [2.26.0]
  • org.seleniumhq.selenium selenium-chrome-driver [2.26.0]
  • org.seleniumhq.selenium selenium-parent [2.26.0]
  • org.seleniumhq.selenium selenium-remote-driver [2.26.0]
  • org.seleniumhq.selenium selenium-support [2.26.0]
  • org.sonatype.oss oss-parent [7]
I Stevenson
  • 854
  • 1
  • 7
  • 24