gpt4 book ai didi

grails - 在 Grails 1.3.7 中使用 Geb、Selenium 和 Spock 进行功能测试时出错

转载 作者:行者123 更新时间:2023-12-02 13:58:10 27 4
gpt4 key购买 nike

我正在尝试使用 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)

我一直在尝试运行这个简单的测试一个星期,但是,所有这些版本和异常(exception)都让我非常困惑。如果有人可以提供帮助,我将不胜感激。

谢谢

最佳答案

这可能是由于包含的 http-client 版本不正确造成的。对我来说,这是由 Grails Release Plugin 引入的。如果它来自插件,您可以在 BuildConfig 中禁用它:

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

关于grails - 在 Grails 1.3.7 中使用 Geb、Selenium 和 Spock 进行功能测试时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10684301/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com