GEB测试。。。驱动程序回调问题

GEB测试。。。驱动程序回调问题,geb,Geb,我有: 和所有需要的罐子。 我正在尝试运行一个简单的GEB程序: 我在模块依赖项中拥有所有groovy JAR,我正在附加buildconfig和gebconfig以及一个新程序及其错误。我知道这个新错误是调用驱动程序的问题,但我需要帮助来解决整个问题。谢谢 BUILDCONFIG.GROOVY • java version "1.6.0_37" • Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-10M3909) •

我有:

和所有需要的罐子。 我正在尝试运行一个简单的GEB程序:

我在模块依赖项中拥有所有groovy JAR,我正在附加buildconfig和gebconfig以及一个新程序及其错误。我知道这个新错误是调用驱动程序的问题,但我需要帮助来解决整个问题。谢谢

BUILDCONFIG.GROOVY

•   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
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

•   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
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"
测试

/*
    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() }

    }

}
错误

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")


    }

    }

}
失败:testLoginLogout(com.test.platform.test.AuthTests)
|geb.driver.DriverCreationException:无法从回调“GebConfig$”创建驱动程序运行\u closure3\u closure5_closure7@c471242'
位于geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
在geb.driver.CachingDriverFactory$\u getDriver\u closure3.doCall(CachingDriverFactory.groovy:80)
在geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
位于geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
在geb.Configuration.createDriver处(Configuration.groovy:306)
位于geb.Configuration.getDriver(Configuration.groovy:295)
在geb.Browser.getDriver(Browser.groovy:101)
在geb.Browser.clearCookies(Browser.groovy:407)
在geb.Browser.ClearCookies(Browser.groovy:415)
位于geb.junit4.GebTest.resetBrowser(GebTest.groovy:46)
原因:java.lang.NoSuchMethodError:org.openqa.selenium.logging.LocalLogs.getNullLogger()Lorg/openqa/selenium/logging/LocalLogs;
位于org.openqa.selenium.firefox.FirefoxDriver$lazycomandexecutor.(FirefoxDriver.java:325)
位于org.openqa.selenium.firefox.FirefoxDriver$lazycomandexecutor。(FirefoxDriver.java:321)
位于org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:188)
位于org.openqa.selenium.firefox.FirefoxDriver(FirefoxDriver.java:183)
位于org.openqa.selenium.firefox.FirefoxDriver(FirefoxDriver.java:179)
位于org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92)
在GebConfig$\u run\u closure3\u closure5\u closure7.doCall(GebConfig.groovy:39)
位于geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 9更多

为什么要使用geb插件0.9.0-RC-1和geb-junit4 0.7.2?您应该对这两个版本使用相同的版本

此外,您不需要在测试中使用Browser.drive块,因为测试中有一个隐式浏览器,它也由基类管理。请看一下,它具有与JUnit基类完全相同的可用变量

因此,您的测试可以简单地如下所示:

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

可能是尝试FF驱动程序

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")
    }

}
在我的项目中,这是工作。
关于其他Brouser,我无能为力。

它仍然显示相同的错误。。。我将geb插件版本更改为0.7.2,但同样的错误重复出现。有什么想法吗?