0

I have:

•   java version "1.6.0_37"

•   Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-10M3909)

•   Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

•   Grails 2.2.0

•   Groovy 2.0

•   GEB core 0.7.2

and all the required jars. I am trying to run a simple GEB program:

I have all the groovy jars in the module dependencies and I am attaching the buildconfig and gebconfig along with a new program and its error. I understand that this new error is an issue with calling the driver but I need help to figure out the entire issue and solve it. thanks

BUILDCONFIG.GROOVY

grails.servlet.version = "2.5" //Change depending on target container compliance(2.5 or 3.0)

grails.project.class.dir = "target/classes"

grails.project.test.class.dir = "target/test-classes"

grails.project.test.reports.dir = "target/test-reports"

grails.project.target.level = 1.6

grails.project.source.level = 1.6

grails.project.war.file = "target/${appName}.war"

grails.project.dependency.resolution = {

    inherits("global") {}

    log "warn"

    checksums true // Whether to verify checksums on resolve

    def gebVersion = "0.7.2"

    def seleniumVersion = "2.25.0"

    repositories {

    inherits true

    }

    dependencies {

    test("org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion") {

        exclude "xml-apis"

    }

    test("org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion")

    test("org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion")

//        test 'org.seleniumhq.selenium:selenium-firefox-driver:latest.release'

//        test 'org.seleniumhq.selenium:selenium-chrome-driver:latest.release'

//

//        test('org.seleniumhq.selenium:selenium-htmlunit-driver:latest.release') {

//            exclude 'xml-apis'

//        }


  test "org.codehaus.geb:geb-junit4:$gebVersion"

    }


    plugins {

    test ":geb:0.9.0-RC-1"


    }
}

// Use a local copy of a platform plugin instead of the installed plugin

grails.plugin.location.platform = "../../plugins/platform"

GEBCONFIG.GROOVY

/*
    This is the Geb configuration file.

    See: http://www.gebish.org/manual/current/configuration.html
*/


import groovy.transform.Field

//import org.openqa.selenium.htmlunit.HtmlUnitDriver

import org.openqa.selenium.firefox.FirefoxDriver

import org.openqa.selenium.chrome.ChromeDriver

// Use htmlunit as the default

// See: http://code.google.com/p/selenium/wiki/HtmlUnitDriver

//driver = {

 //def driver = new HtmlUnitDriver()

  // driver.javascriptEnabled = true

   // driver

//}

driver= {

    new FirefoxDriver()

}

waiting {

    timeout = 5

}


environments {

    // run as “grails -Dgeb.env=chrome SampleTests-app”
    // See: http://code.google.com/p/selenium/wiki/ChromeDriver

   chrome {

    driver = { new ChromeDriver() }

    }

    // run as “grails -Dgeb.env=firefox SampleTests-app”
    // See: http://code.google.com/p/selenium/wiki/FirefoxDriver

    firefox {

       driver = { new FirefoxDriver() }

    }

}

TEST

package com.test.platform.test


import geb.junit4.GebReportingTest

import geb.Browser

import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils



class AuthTests extends GebReportingTest {

    void testLoginLogout() {

    Browser.drive {

        //goto login page & assert location

        go("http://localhost:8080/test")

        assert (getTitle() == "Welcome to test")


    }

    }

}

ERROR

Failure:  testLoginLogout(com.test.platform.test.AuthTests)
|  geb.driver.DriverCreationException: failed to create driver from callback 'GebConfig$_run_closure3_closure5_closure7@c471242'
    at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
    at geb.driver.CachingDriverFactory$_getDriver_closure3.doCall(CachingDriverFactory.groovy:80)
    at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
    at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
    at geb.Configuration.createDriver(Configuration.groovy:306)
    at geb.Configuration.getDriver(Configuration.groovy:295)
    at geb.Browser.getDriver(Browser.groovy:101)
    at geb.Browser.clearCookies(Browser.groovy:407)
    at geb.Browser.clearCookiesQuietly(Browser.groovy:415)
    at geb.junit4.GebTest.resetBrowser(GebTest.groovy:46)
Caused by: java.lang.NoSuchMethodError: org.openqa.selenium.logging.LocalLogs.getNullLogger()Lorg/openqa/selenium/logging/LocalLogs;
    at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.<init>(FirefoxDriver.java:325)
    at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.<init>(FirefoxDriver.java:321)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:188)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:179)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
    at GebConfig$_run_closure3_closure5_closure7.doCall(GebConfig.groovy:39)
    at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
    ... 9 more
erdi
  • 6,944
  • 18
  • 28
Dee
  • 223
  • 5
  • 11

2 Answers2

1

Why are you using geb plugin 0.9.0-RC-1 and geb-junit4 0.7.2? You should be using the same version for both of them.

Also, you don't need to use Browser.drive block in your tests as there is an implicit browser available in your tests which is also managed by the base class. Have a look at the Spock example in Geb docs, which has exactly the same variables available as the JUnit base class.

So, your test could simply look like:

package com.test.platform.test

import geb.junit4.GebReportingTest
import geb.Browser

class AuthTests extends GebReportingTest {

    void testLoginLogout() {
        go("http://localhost:8080/test")

        assert(getTitle() == "Welcome to test")
    }

}
erdi
  • 6,944
  • 18
  • 28
  • It still shows the same error... I changed the geb plugin version to 0.7.2 but the same error repeats. Any ideas? – Dee Feb 05 '13 at 20:27
0

May be try this for FF driver

{   
    FirefoxBinary firefoxBinary = new FirefoxBinary()
    firefoxBinary.setEnvironmentProperty("DISPLAY",":77")
    firefoxBinary.setTimeout(20000l)
    FirefoxProfile profile = new FirefoxProfile()

    driver = {  
        new FirefoxDriver(firefoxBinary, profile)
    }
}

On my project it's work. About other brousers, i can't help.

plsgogame
  • 1,334
  • 15
  • 28