Вопрос

I'm trying to run functional tests using Grails 1.3.7, Geb, Spock, and Selenium. Here's my BuildConfig.groovy file:

         def seleniumVersion = "2.21.0"

    grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global")
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    test("org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion")
    test("org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion")
    test "org.codehaus.geb:geb-spock:0.6.0"
}

plugins {
    test(":spock:0.5-groovy-1.7")
}

The test code is like this:

LoginPage.groovy:

package pages

import geb.Page

class LoginPage extends Page
{

static url = 'login'

static at = { title.endsWith("Login")}
}

GeneralSpec.groovy:

import geb.spock.GebReportingSpec
import spock.lang.*
import pages.*

@Stepwise
class GeneralSpec extends GebReportingSpec
{

    def "I can access the login page"()
    {
        when: "I open the login page"
        to LoginPage

        then: "I'll be at the login page"
        at LoginPage
    }

}

Now, when trying to run this test with the FirefoxDriver, I get this error:

org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
    at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:59)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:48)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:111)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:78)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:200)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:85)
    at geb.driver.NameBasedDriverFactory.getDriver(NameBasedDriverFactory.groovy:42)
    at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:36)
    at geb.Configuration.createDriver(Configuration.groovy:210)
    at geb.Configuration.getDriver(Configuration.groovy:199)
    at geb.Browser.getDriver(Browser.groovy:100)
    at geb.Browser.go(Browser.groovy:300)
    at geb.Page.to(Page.groovy:157)
    at geb.Browser.to(Browser.groovy:333)
    at geb.Browser.to(Browser.groovy:323)
    at geb.Browser.to(Browser.groovy:313)
    at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
    at GeneralSpec.I can access the login page(GeneralSpec.groovy:12)
org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
    at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:59)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:48)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:111)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:78)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:200)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:85)
    at geb.driver.NameBasedDriverFactory.getDriver(NameBasedDriverFactory.groovy:42)
    at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:36)
    at geb.Configuration.createDriver(Configuration.groovy:210)
    at geb.Configuration.getDriver(Configuration.groovy:199)
    at geb.Browser.getDriver(Browser.groovy:100)
    at geb.report.PageSourceReporter.getPageSource(PageSourceReporter.groovy:39)
    at geb.report.PageSourceReporter.writePageSource(PageSourceReporter.groovy:35)
    at geb.report.PageSourceReporter.writeReport(PageSourceReporter.groovy:27)
    at geb.report.ScreenshotAndPageSourceReporter.writeReport(ScreenshotAndPageSourceReporter.groovy:31)
    at geb.Browser.report(Browser.groovy:453)
    at geb.spock.GebReportingSpec.report(GebReportingSpec.groovy:43)
    at geb.spock.GebReportingSpec.cleanup(GebReportingSpec.groovy:39)

I've been trying to run this simple test for a week, however, all these versions and exceptions have me very much confused. I'd appreciate it a lot if anyone could help.

Thanks

Это было полезно?

Решение

This can be caused by an incorrect version of http-client being included. For me, this was pulled in by the Grails Release Plugin. If it's coming from a plugin, you can disable it in BuildConfig:

plguins {
    build ":release:$grailsVersion" {
        excludes = 'http-client'
    }
}

Другие советы

(edit) It depends which version of Firefox you are targeting. I am running against Firefox 3.6.28. Using Grails 1.3.7 and Geb 0.6.1

(edit 2) You can use selenium version - 2.21.0.

The quick fix is to change to the following.

(edit 2) def seleniumVersion = "2.21.0"

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top