升级到 Grails 2.4.5 后的 Geb 驱动程序问题
Geb driver issue after upgrading to Grails 2.4.5
将我的 Grails 版本从 2.3.6 升级到 2.4.5 后,我现在在 运行ning Geb Spock 测试时遇到异常。
failed to create driver from callback 'script14328041759692122350870$_run_closure1@5fcdf5ea'
geb.driver.DriverCreationException: failed to create driver from callback 'script14328041759692122350870$_run_closure1@5fcdf5ea'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:85)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84)
at geb.Configuration.createDriver(Configuration.groovy:361)
at geb.Configuration.getDriver(Configuration.groovy:350)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.clearCookies(Browser.groovy:496)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:54)
at AuthorizationAdminSpec.setupSpec(AuthorizationAdminSpec.groovy:21)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:234)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:211)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:88)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:57)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
at script14328041759692122350870.run_closure1(script14328041759692122350870.groovy:12)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 9 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.SchemePortResolver
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 23 more
我记得之前在 Grails 2.3.6 中初始设置 Geb 时遇到过这个异常,其中 BuildConfig 和 GebConfig 文件没有正确配置。然而,在重新检查 Geb 所需的必要插件和依赖项时,我没有注意到 Grails 2.4.5 有什么不同另外,我将依赖项解析从 Ivy 切换到 Maven,所以我仔细检查了我的 maven 资源以确保驱动程序已加载。
更多信息...
BuildConfig.groovy
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo "http://google-api-client-libraries.appspot.com/mavenrepo"
mavenRepo "http://mvnrepository.com/artifact/"
mavenRepo "http://repo.jenkins-ci.org/repo"
mavenRepo "http://repo.grails.org/grails/repo"
}
dependencies {
....
compile "org.springframework:spring-test:4.0.9.RELEASE"
test "org.gebish:geb-spock:0.10.0"
test "org.seleniumhq.selenium:selenium-support:2.45.0"
test "org.seleniumhq.selenium:selenium-firefox-driver:2.45.0"
}
plugins {
....
test ":geb:0.10.0"
}
GebConfig.groovy
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
reportsDir = "target/geb-reports"
baseUrl = "http://localhost:8090/adverity/"
driver = {
//set the firefox locale to 'en-us' since the tests expect english
//see for more details
FirefoxProfile profile = new FirefoxProfile()
profile.setPreference("intl.accept_languages", "en-us")
def driverInstance = new FirefoxDriver(profile)
driverInstance.manage().window().maximize()
driverInstance
}
baseNavigatorWaiting = true
atCheckWaiting = true
autoClearCookies = false
quitCachedDriverOnShutdown = false
我 运行 会抛出相同的任何简单规范 error.I 尝试用 Chrome 做同样的事情来测试这是否是驱动程序问题并得到相同的结果。 firefox 和 Chrome 驱动程序均适用于 Grails 2.3.6,但不适用于 2.4.5。
- OS:软呢帽 20
- 浏览器:Firefox 38
我已经看过的地方...
- 盖布之书
- GebGrails git 集线器示例
- 计算器溢出
test 'org.apache.httpcomponents:httpclient:4.3.2'
已添加到 BuildConfig.groovy
中的依赖项部分
我没有意识到这种依赖性,因为我没有在任何文档中看到它,但深入查看堆栈跟踪告诉我并非如此。
将我的 Grails 版本从 2.3.6 升级到 2.4.5 后,我现在在 运行ning Geb Spock 测试时遇到异常。
failed to create driver from callback 'script14328041759692122350870$_run_closure1@5fcdf5ea'
geb.driver.DriverCreationException: failed to create driver from callback 'script14328041759692122350870$_run_closure1@5fcdf5ea'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:85)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84)
at geb.Configuration.createDriver(Configuration.groovy:361)
at geb.Configuration.getDriver(Configuration.groovy:350)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.clearCookies(Browser.groovy:496)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:54)
at AuthorizationAdminSpec.setupSpec(AuthorizationAdminSpec.groovy:21)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:234)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:211)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:88)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:57)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
at script14328041759692122350870.run_closure1(script14328041759692122350870.groovy:12)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 9 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.SchemePortResolver
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 23 more
我记得之前在 Grails 2.3.6 中初始设置 Geb 时遇到过这个异常,其中 BuildConfig 和 GebConfig 文件没有正确配置。然而,在重新检查 Geb 所需的必要插件和依赖项时,我没有注意到 Grails 2.4.5 有什么不同另外,我将依赖项解析从 Ivy 切换到 Maven,所以我仔细检查了我的 maven 资源以确保驱动程序已加载。
更多信息...
BuildConfig.groovy
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo "http://google-api-client-libraries.appspot.com/mavenrepo"
mavenRepo "http://mvnrepository.com/artifact/"
mavenRepo "http://repo.jenkins-ci.org/repo"
mavenRepo "http://repo.grails.org/grails/repo"
}
dependencies {
....
compile "org.springframework:spring-test:4.0.9.RELEASE"
test "org.gebish:geb-spock:0.10.0"
test "org.seleniumhq.selenium:selenium-support:2.45.0"
test "org.seleniumhq.selenium:selenium-firefox-driver:2.45.0"
}
plugins {
....
test ":geb:0.10.0"
}
GebConfig.groovy
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
reportsDir = "target/geb-reports"
baseUrl = "http://localhost:8090/adverity/"
driver = {
//set the firefox locale to 'en-us' since the tests expect english
//see for more details
FirefoxProfile profile = new FirefoxProfile()
profile.setPreference("intl.accept_languages", "en-us")
def driverInstance = new FirefoxDriver(profile)
driverInstance.manage().window().maximize()
driverInstance
}
baseNavigatorWaiting = true
atCheckWaiting = true
autoClearCookies = false
quitCachedDriverOnShutdown = false
我 运行 会抛出相同的任何简单规范 error.I 尝试用 Chrome 做同样的事情来测试这是否是驱动程序问题并得到相同的结果。 firefox 和 Chrome 驱动程序均适用于 Grails 2.3.6,但不适用于 2.4.5。
- OS:软呢帽 20
- 浏览器:Firefox 38
我已经看过的地方...
- 盖布之书
- GebGrails git 集线器示例
- 计算器溢出
test 'org.apache.httpcomponents:httpclient:4.3.2'
已添加到 BuildConfig.groovy
中的依赖项部分我没有意识到这种依赖性,因为我没有在任何文档中看到它,但深入查看堆栈跟踪告诉我并非如此。