Gradle/Spock/Geb org.openqa.selenium.firefox.NotConnectedException 在 Linux 但适用于 Windows

Gradle/Spock/Geb org.openqa.selenium.firefox.NotConnectedException on Linux but works on Windows

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

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

org.openqa.selenium.WebDriverException at LoginTest.groovy:9 Caused by: org.openqa.selenium.firefox.NotConnectedException at LoginTest.groovy:9 org.openqa.selenium.WebDriverException Caused by: org.openqa.selenium.firefox.NotConnectedException

当 运行 打开空白浏览器 window 且未输入 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"
    }

}

Geb

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

}

When run a blank browser window is opened and the URL is not entered

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