本文介绍了为什么我的Geb测试返回“无法从回调创建驱动程序”即使在Grails中更新我的Selenium依赖项后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我引用了此前的线程() - 但仍然有问题。



我试图在Grails 2.4.3和I下运行Geb功能测试将我的Selenium支持依赖项设置为版本2.42.2。我也尝试了2.43.1和2.45.0。如果我尝试使用Selenium 2.42.2或2.43.1,Geb会停止运行并且不能完成,如果我使用2.45.0,Geb将彻底崩溃。



这些错误我得到:

$ ol
如果我尝试Selenium支持2.42.2或2.43.1,我得到这个错误:geb.driver。 DriverCreationException:无法从回调中创建驱动程序

  • 如果我尝试Selenium支持2.45.0 - 我的浏览器将尝试运行Geb测试,但会返回一个The页面不能重定向错误。

    在我的Grails BuildConfig.groovy中,这里是硒依赖关系它立即设置:

      def seleniumVersion =2.45.0

    依赖关系{
    //在构建,编译,运行时,测试或提供的范围下指定依赖关系
    // runtime'mysql:mysql-connector-java:5.1.29'
    // runtime'org.postgresql:postgresql:9.3-1101-jdbc41'
    compile'org.dbunit: dbunit:2.5.0'
    testorg.seleniumhq.selenium:selenium-firefox-driver:$ seleniumVersion
    testorg.gebish:geb-spock:$ gebVersion
    compile org.springframework:spring-orm:4.0.5.RELEASE
    //需要选择对象
    testorg.seleniumhq.selenium:selenium-support:2.45.0



    解决方案



      gebVersion ='0.10.0'
    seleniumVersion ='2.43.1'

    有一点额外的信息,我有一个Gradle项目只用于运行Geb测试,这是Geb特定的数据我的 build.gradle 文件。我知道这些版本可以一起工作,希望它们对你有用。

      ext {
    // The我们想要使用
    drivers的驱动程序= [firefox,chrome,phantomJs]

    ext {
    groovyVersion ='2.3.6'
    gebVersion ='0.10.0'
    seleniumVersion ='2.43.1'
    chromeDriverVersion ='2.10'
    phantomJsVersion ='1.9.7'
    }
    }

    依赖关系{
    //如果使用Spock,需要依赖geb-spock
    testCompileorg.gebish:geb-spock:$ gebVersion
    testCompile(org。 spockframework:spock-core:0.7-groovy-2.0){
    exclude group:org.codehaus.groovy
    }
    testCompileorg.codehaus.groovy:groovy-all:$ groovyVersion

    //驱动程序
    testCompileorg.seleniumhq.selenium:selenium-chrome-driver:$ seleniumVersion
    testCompileorg.seleniumhq.selenium:selenium-firefox-驱动程序:$ seleniumVersion
    testCompile(com.github.detro.ghostdriver:phantomjsdriver:1.1.0){
    // phantomjs驱动程序使用不同的硒版本
    transitive = false
    }
    }


    I am referencing this previous thread (geb.driver.DriverCreationException: failed to create driver from callback) - but am still having problems.

    I am trying to run Geb functional tests under Grails 2.4.3 and I have my Selenium support dependency set to version 2.42.2. I've also tried it with 2.43.1 and 2.45.0. Geb will stall out and not finish if I try Selenium 2.42.2 or 2.43.1, and it will outright crash if I use 2.45.0.

    These are the errors I get:

    1. If I try Selenium support 2.42.2 or 2.43.1, I get this error: geb.driver.DriverCreationException: failed to create driver from callback

    2. If I try Selenium support 2.45.0 - My browser will try to run the Geb test but will return a "The Page Is Not Redirectly Properly" error.

    In my Grails BuildConfig.groovy, here is the selenium dependency as I have it set right now:

     def seleniumVersion = "2.45.0"
    
      dependencies {
            // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
            // runtime 'mysql:mysql-connector-java:5.1.29'
            // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
            compile 'org.dbunit:dbunit:2.5.0'
            test "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
            test "org.gebish:geb-spock:$gebVersion"
            compile "org.springframework:spring-orm:4.0.5.RELEASE"
            // need for select objects
            test "org.seleniumhq.selenium:selenium-support:2.45.0"
    
        }
    
    解决方案

    I have Geb working with the following properties:

    gebVersion = '0.10.0'
    seleniumVersion = '2.43.1'
    

    For a little extra info, I have a Gradle project that is only used to run Geb tests, and this is the Geb specific data in my build.gradle file. I know these versions will work together, hopefully they can be of use to you.

    ext {
        // The drivers we want to use
        drivers = ["firefox", "chrome", "phantomJs"]
    
        ext {
            groovyVersion = '2.3.6'
            gebVersion = '0.10.0'
            seleniumVersion = '2.43.1'
            chromeDriverVersion = '2.10'
            phantomJsVersion = '1.9.7'
        }
    }
    
    dependencies {
        // If using Spock, need to depend on geb-spock
        testCompile "org.gebish:geb-spock:$gebVersion"
        testCompile("org.spockframework:spock-core:0.7-groovy-2.0") {
            exclude group: "org.codehaus.groovy"
        }
        testCompile "org.codehaus.groovy:groovy-all:$groovyVersion"
    
        // Drivers
        testCompile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
        testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
        testCompile("com.github.detro.ghostdriver:phantomjsdriver:1.1.0") {
            // phantomjs driver pulls in a different selenium version
            transitive = false
        }
    }
    

    这篇关于为什么我的Geb测试返回“无法从回调创建驱动程序”即使在Grails中更新我的Selenium依赖项后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 10-30 07:14