我試圖運行使用Grails 1.3.7,蓋布,斯波克和硒功能測試。這是我的BuildConfig.groovy文件:錯誤使用蓋布,硒和斯波克當Grails的功能測試1.3.7
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")
}
測試代碼是這樣的:
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
}
}
現在,當嘗試運行這個測試與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)
我一直在嘗試運行了一個星期這個簡單的測試,但是,所有這些版本和異常有我很困惑。如果有人能提供幫助,我會很感激。
感謝
感謝您的回答。如果你在我原來的問題看,我使用seleniumVersion = 2.21.0爲好。我正在使用最新的Firefox(13.0)。 –