【问题标题】:Gradle/Spock/Geb org.openqa.selenium.firefox.NotConnectedException on Linux but works on WindowsGradle/Spock/Geb org.openqa.selenium.firefox.NotConnectedException 在 Linux 上,但在 Windows 上有效
【发布时间】:2015-02-20 23:54:19
【问题描述】:

我有一个 gradle 脚本,它将 geb.build.baseUrl 设置为项目属性。这也不适用于静态 url。

这在 Windows 上运行良好,但在 Linux 上我遇到了以下问题:

org.openqa.selenium.WebDriverException 在 LoginTest.groovy:9 引起:LoginTest.groovy:9 的 org.openqa.selenium.firefox.NotConnectedException org.openqa.selenium.WebDriverException 引起:org.openqa.selenium.firefox.NotConnectedException

运行时会打开一个空白浏览器窗口且未输入 URL:

Gradle

apply plugin: "groovy"

repositories {
    mavenCentral()
}

configurations {
    testCompile.transitive = true
}

dependencies {

    def gebVersion = "0.10.0"
    def seleniumVersion = "2.43.1"

    testCompile "org.gebish:geb-spock:0.10.0"
    testCompile "org.spockframework:spock-core:0.7-groovy-2.0"

    // Need a driver implementation
    testCompile "org.seleniumhq.selenium:selenium-firefox-driver:2.43.1"
    testRuntime "org.seleniumhq.selenium:selenium-support:2.43.1"

    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile "org.gebish:geb-junit4:$gebVersion"
}

test {
    systemProperties "geb.build.reportsDir": "$reportsDir/geb"
    systemProperties "geb.build.baseUrl": project.url
}

斯波克

package xx.xx;

import geb.spock.GebReportingSpec

class LoginSpec extends GebReportingSpec {

    def "login"() {
        when:
            to Login
            report "login screen"
        and:
            login(username,password)
        then:
            at Dashboard
        where:
            username   | password
            "X"        | "X"
    }

}

盖布

package xx.xx;

import geb.*

class Login extends Page {
    static at = { title == "xx"}
    static content = {
        usernameField { $("input",id:"pt1:it1::content")}
        passwordField { $("input",id:"pt1:it2::content")}
        loginButton(to: Dashboard) { $("span",id: "pt1:pgl13") }
    }

    void login(String username, String password) {
        usernameField.value username
        passwordField.value password
        loginButton.click()
    }
}

class Dashboard extends Page {
    static at = { title == "xx"}

}

【问题讨论】:

    标签: selenium gradle spock geb


    【解决方案1】:

    运行时会打开一个空白浏览器窗口并且没有输入 URL

    根据我的经验,这通常是因为使用的 Firefox 版本比所用的 WebDriver 版本支持的版本更新。我建议使用selenium-firefox-driver 2.44.0,如果症状仍然存在,请尝试降级 Firefox。

    【讨论】:

    • 在回复我的Firefox浏览器时是36.0.1。我不得不将 firefox 驱动程序和 selenium-support jar 的版本更改为 2.45.0
    猜你喜欢
    • 2019-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-21
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    相关资源
    最近更新 更多