Java geb geckodriver工作不正常(启动多浏览器窗口)
我想在多个浏览器中使用geb,特别是在firefox中。然而,我让firefox在没有插入url的情况下启动多个窗口,最终失败了。然而,我对chrome没有任何问题。Chrome工作正常。我正在使用firefox 57.0.4(32位)、geckodriver 0.20.1和selenium 3.11.0 这就是我在GebConfig.groovy文件中对firefox(geckodriver)进行配置的方式Java geb geckodriver工作不正常(启动多浏览器窗口),java,selenium-webdriver,groovy,automated-tests,geb,Java,Selenium Webdriver,Groovy,Automated Tests,Geb,我想在多个浏览器中使用geb,特别是在firefox中。然而,我让firefox在没有插入url的情况下启动多个窗口,最终失败了。然而,我对chrome没有任何问题。Chrome工作正常。我正在使用firefox 57.0.4(32位)、geckodriver 0.20.1和selenium 3.11.0 这就是我在GebConfig.groovy文件中对firefox(geckodriver)进行配置的方式 driver = { System.setProperty("webd
driver = {
System.setProperty("webdriver.gecko.driver", "C:\\Data\\selenium\\geckodriver.exe")
DesiredCapabilities capabilities = DesiredCapabilities.firefox()
capabilities.setCapability("marionette", true);
new FirefoxDriver(capabilities)
}
我还尝试了以下简单配置:
driver="org.openqa.selenium.firefox.FirefoxDriver"
他们都打开了多个新窗口,特别是9个新的firefox窗口,但都失败了,然后崩溃了。下面是堆栈跟踪
1524422284063 geckodriver INFO geckodriver 0.20.1
1524422284107 geckodriver INFO Listening on 127.0.0.1:23600
1524422284801 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.t9ACOIsvj903"
1524422286509 Marionette INFO Enabled via --marionette
[Parent 5248, Gecko_IOThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 6128, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 6128, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422290031 Marionette INFO Listening on port 53659
1524422290543 Marionette DEBUG Register listener.js for window
4294967297
1524422291404 geckodriver INFO geckodriver 0.20.1
1524422291444 geckodriver INFO Listening on 127.0.0.1:37977
1524422291888 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.TDpwyZXqxyTB"
1524422293344 Marionette INFO Enabled via --marionette
[Parent 9756, Gecko_IOThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422296749 Marionette INFO Listening on port 60160
1524422297189 Marionette DEBUG Register listener.js for window
4294967297
1524422298143 geckodriver INFO geckodriver 0.20.1
1524422298191 geckodriver INFO Listening on 127.0.0.1:32782
1524422298377 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.yBcRA1dKXoGT"
1524422299521 Marionette INFO Enabled via --marionette
[Child 16340, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422302872 Marionette INFO Listening on port 63356
1524422303045 Marionette DEBUG Register listener.js for window
4294967297
1524422303852 geckodriver INFO geckodriver 0.20.1
1524422303895 geckodriver INFO Listening on 127.0.0.1:19586
1524422304228 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.9ev5FY0xc1i7"
1524422305543 Marionette INFO Enabled via --marionette
[GFX1-]: Could not get a DXGI adapter
[GFX1-]: Could not get a DXGI adapter
[Child 14868, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 14868, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422310032 Marionette INFO Listening on port 64844
[GFX1-]: Could not get a DXGI adapter
1524422310604 Marionette DEBUG Register listener.js for window
4294967297
1524422321813 geckodriver INFO geckodriver 0.20.1
1524422321858 geckodriver INFO Listening on 127.0.0.1:26836
1524422322191 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.ibDRBSonhkXz"
1524422323777 Marionette INFO Enabled via --marionette
[GFX1-]: Could not get a DXGI adapter
[GFX1-]: ClientLayerManager::BeginTransaction with IPC channel down. GPU
process may have died.
[Parent 10436, Gecko_IOThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 16792, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 16792, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[GFX1-]: Could not get a DXGI adapter
1524422327647 Marionette INFO Listening on port 49671
1524422327909 Marionette DEBUG Register listener.js for window
4294967297
[GFX1-]: Could not get a DXGI adapter
1524422328854 geckodriver INFO geckodriver 0.20.1
1524422328899 geckodriver INFO Listening on 127.0.0.1:41041
1524422329094 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.nF37Bcb1rsbM"
1524422330408 Marionette INFO Enabled via --marionette
[Parent 10360, Gecko_IOThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 12412, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 12412, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422335433 Marionette INFO Listening on port 55596
1524422335714 Marionette DEBUG Register listener.js for window
4294967297
1524422336611 geckodriver INFO geckodriver 0.20.1
1524422336657 geckodriver INFO Listening on 127.0.0.1:44307
1524422337007 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.BZK9Y7YfOaPw"
1524422338399 Marionette INFO Enabled via --marionette
[Child 5860, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 5860, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422348219 Marionette INFO Listening on port 65437
1524422348734 Marionette DEBUG Register listener.js for window
4294967297
1524422350248 geckodriver INFO geckodriver 0.20.1
1524422350322 geckodriver INFO Listening on 127.0.0.1:36341
1524422350716 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.WMfmoDbCDTAT"
1524422353025 Marionette INFO Enabled via --marionette
[Child 10468, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
[Child 10468, Chrome_ChildThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422358314 Marionette INFO Listening on port 56794
1524422358557 Marionette DEBUG Register listener.js for window
4294967297
1524422359719 geckodriver INFO geckodriver 0.20.1
1524422359781 geckodriver INFO Listening on 127.0.0.1:29271
1524422360457 mozrunner::runner INFO Running command: "C:\\Program
Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile"
"C:\\Users\\My user
name\\AppData\\Local\\Temp\\rust_mozprofile.L8VJnzbpCkrK"
1524422362362 Marionette INFO Enabled via --marionette
[Parent 6760, Gecko_IOThread] WARNING: pipe error: 109: file
z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line
346
1524422368470 Marionette INFO Listening on port 54188
1524422368810 Marionette DEBUG Register listener.js for window
4294967297
Tests run: 6, Failures: 0, Errors: 6, Skipped: 0, Time elapsed: 102.379 sec
<<< FAILURE! - in MyTestSuite
mytestfunction(MyTestSuite) Time elapsed: 29.182 sec <<< ERROR!
geb.driver.DriverCreationException: failed to create driver from callback '
script1524422266628441905114$_run_closure1@2643ed03'
at MyTestSuite.mytestfunction(MyTestSuite.groovy:25)
Caused by: org.openqa.selenium.SessionNotCreatedException:
Unable to create new remote session. desired capabilities = Capabilities
[{marionette=true, browserName=firefox, moz:firefoxOptions=
{binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={},
profile=null}, version=, platform=ANY}], required capabilities =
Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[],
legacy=null, logLevel=null, prefs={}, profile=null}}]
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10
09:10:29 +0000'
System info: host: 'Hostname', ip: 'xxx.xxx.xx.xx', os.name: 'Windows 7',
os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: driver.version: FirefoxDriver
这是GebishOrgSpec.groovy文件
import geb.spock.GebSpec
class GebishOrgSpec extends GebSpec {
def "can get to the current Book of Geb"() {
when:
to GebishOrgHomePage
and:
manualsMenu.open()
then:
manualsMenu.links[0].text().startsWith("current")
when:
manualsMenu.links[0].click()
then:
at TheBookOfGebPage
}
}
import geb.Page
class GebishOrgHomePage extends Page {
static at = { title == "Geb - Very Groovy Browser Automation" }
static content = {
manualsMenu { module(ManualsMenuModule) }
}
下面是GebishOrgHomePage.groovy文件
import geb.spock.GebSpec
class GebishOrgSpec extends GebSpec {
def "can get to the current Book of Geb"() {
when:
to GebishOrgHomePage
and:
manualsMenu.open()
then:
manualsMenu.links[0].text().startsWith("current")
when:
manualsMenu.links[0].click()
then:
at TheBookOfGebPage
}
}
import geb.Page
class GebishOrgHomePage extends Page {
static at = { title == "Geb - Very Groovy Browser Automation" }
static content = {
manualsMenu { module(ManualsMenuModule) }
}
}
这是手册SMenuModule.groovy
import geb.Module
class ManualsMenuModule extends Module {
static content = {
toggle { $("div.menu a.manuals") }
linksContainer { $("#manuals-menu") }
links { linksContainer.find("a") }
}
void open() {
toggle.click()
waitFor { !linksContainer.hasClass("animating") }
}
}
这是TheBookOfGebPage.groovy
import geb.Page
class TheBookOfGebPage extends Page {
static at = { title.startsWith("The Book Of Geb") }
}
这是pom
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gebish.example</groupId>
<artifactId>geb-maven-example</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>Geb Maven Example</name>
<url>http://gebish.org</url>
<properties>
<gebVersion>1.1.1</gebVersion>
<seleniumVersion>3.3.1</seleniumVersion>
<groovyVersion>2.4.11</groovyVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovyVersion}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.0-groovy-2.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>${gebVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${seleniumVersion}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${seleniumVersion}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-ie-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>${seleniumVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<includes>
<include>*Spec.*</include>
</includes>
<systemPropertyVariables>
<geb.build.reportsDir>target/test-reports/geb</geb.build.reportsDir>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>com.rimerosolutions.maven.plugins</groupId>
<artifactId>wrapper-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<mavenVersion>3.3.3</mavenVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovyVersion}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.github.webdriverextensions</groupId>
<artifactId>webdriverextensions-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<goals>
<goal>install-drivers</goal>
</goals>
</execution>
</executions>
<configuration>
<drivers>
<driver>
<name>chromedriver</name>
<version>2.36</version>
<platform>windows</platform>
</driver>
<!-- <driver>
<name>chromedriver</name>
<version>2.36</version>
<platform>windows</platform>
</driver>-->
<!-- <driver>
<name>geckodriver</name>
<version>0.14.0</version>
<platform>windows</platform>
</driver>-->
<driver>
<name>geckodriver</name>
<version>0.20.1</version>
<platform>windows</platform>
</driver>
</drivers>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e
settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.github.webdriverextensions
</groupId>
<artifactId>
webdriverextensions-maven-plugin
</artifactId>
<versionRange>
[3.1.1,)
</versionRange>
<goals>
<goal>install-drivers</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.gmaven
</groupId>
<artifactId>
gmaven-plugin
</artifactId>
<versionRange>[1.5,)</versionRange>
<goals>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
4.0.0
org.gebish.example
gebmaven示例
罐子
1.
gebmaven示例
http://gebish.org
1.1.1
3.3.1
2.4.11
UTF-8
UTF-8
org.codehaus.groovy
groovy all
${groovyVersion}
朱尼特
朱尼特
4.12
测试
com.opencsv
opencsv
4.1
org.apache.poi
poi
3.9
org.apache.poi
poi ooxml
3.9
org.apache.poi
poi ooxml模式
3.9
org.apache.xmlbeans
xmlbeans
2.6.0
org.spockframework
斯波克堆芯
1.0-groovy-2.4
测试
org.codehaus.groovy
groovy all
org.gebish
格布·斯波克
${gebVersion}
测试
org.seleniumhq.selenium
硒铬驱动器
${seleniumVersion}
测试
org.seleniumhq.selenium
selenium firefox驱动程序
${seleniumVersion}
测试
org.seleniumhq.selenium
汽车驾驶员
${seleniumVersion}
测试
org.apache.commons
commons-lang3
3.5
测试
org.apache.maven.plugins
maven surefire插件
2.19
*规格*
目标/测试报告/geb
com.rimerosolutions.maven.plugins
包装maven插件
0.0.4
3.3.3
org.codehaus.gmaven
gmaven插件
1.5
测试编译
org.codehaus.groovy
groovy all
${groovyVersion}
com.github.webdrivelex
WebDriveMaven插件
3.1.1
安装驱动程序
镀铬器
2.36
窗户
壁虎河
0.20.1
窗户
org.eclipse.m2e
生命周期映射
1.0.0
com.github.webdrivelex
WebDriveMaven插件
[3.1.1,)
安装驱动程序
org.codehaus.gmaven
gmaven插件
[1.5,)
测试编译
`我在尝试使用x64驱动程序时遇到了类似的问题。每个版本>0.14.0都会出现这种症状(4个空的浏览器窗口,4个需要手动删除的geckodriver.exe实例)。一旦我将我的项目恢复到0.14.0,即使使用当前的FF Quantum 59.0.2(64位),一切都会恢复正常 当然,这不是一个解决方案,而是一个解决办法。如果有Geckodriver的对应票据,我不知道。我还没有检查
更新:我仍在使用Selenium 3.0.1。也许这就是为什么我不能使用never版本的Geckodriver,因为在网站上,它说驱动程序版本0.15至少需要Selenium 3.3。但正如你所说,使用Selenium 3.11应该不会有问题。即使Geckodriver 0.19.0也只需要Selenium 3.5。但也许你的Maven套件up有缺陷,不知何故它引入了一个旧的Selenium版本。你可以检查一下。我同意kriegaex的说法,这很可能是某种WebDriver+geckodriver+FF版本不兼容。我会首先尝试将你的FF升级到最新版本,如果这没有帮助,我会开始降级WebDriver和geckodriver。我可以确认在本地,FF 56.0.2、WebDriver 3.6.0和geckodriver 0.19.0的组合对我来说是可行的。不幸的是,我仍然有同样的问题。对于selenium 3.0.1和geckodriver 0.14.0,我有一个窗口打开了一段时间,但url没有填写,大约30分钟后,新窗口打开。然后请提供一个完整的、最小的项目()包括Maven build,这样我可以重现你的问题。GitHub会很好。顺便说一句,如果可以选择的话,你也可以尝试64位而不是32位。这是我们目前可以看到的设置之间的差异。但是现在说代码,而不仅仅是散文,会更好。这是StackOverflow。Th