我正在尝试使用 Grails 1.3.7、Geb、Spock 和 Selenium 运行功能测试。这是我的 BuildConfig.groovy 文件:
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")
}
测试代码是这样的:
登录页面.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
}
}
现在,当尝试使用 FirefoxDriver 运行此测试时,我收到此错误:
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)
我已经尝试运行这个简单的测试一周了,但是,所有这些版本和异常都让我非常困惑。如果有人可以提供帮助,我将不胜感激。
谢谢