geb geckodriver not working properly (launching multiple browser window)

天涯浪子 提交于 2019-12-11 00:23:52

问题


I want to use geb with multiple browsers, specifically with firefox. However I am getting the firefox launching multiple windows without inserting the url., and ultimately failing. However, I have had no problem with chrome. Chrome is working perfectly. I am using firefox 57.0.4 (32-Bit), geckodriver 0.20.1 and selenium 3.11.0.

This is how I did the configuration for firefox(geckodriver) in the GebConfig.groovy file.

driver = {
        System.setProperty("webdriver.gecko.driver", "C:\\Data\\selenium\\geckodriver.exe")
        DesiredCapabilities capabilities = DesiredCapabilities.firefox()
        capabilities.setCapability("marionette", true);
         new FirefoxDriver(capabilities)
     }

I have also tried a simple configuration like this:

driver="org.openqa.selenium.firefox.FirefoxDriver"

They are all opening multiple new windows, specifically 9 new firefox windows all failing, before crashing. Below is the stack trace.

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

I am confused right now because sofar all possible solutions on the forum are not working.

Here is the GebConfig.groovy file:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.os.ExecutableFinder
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

 reportsDir = "target/geb-reports"
 driver = null

    driver = {
    System.setProperty("webdriver.gecko.driver", "D:\\eclipse-jee-workspace\\geb-example-maven\\drivers\\geckodriver.exe")
    DesiredCapabilities capabilities = DesiredCapabilities.firefox()
    capabilities.setCapability("marionette", true);
    new FirefoxDriver(capabilities)
 }




baseUrl = "http://gebish.org"

This is the GebishOrgSpec .groovy file

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
  }
}

Here is the GebishOrgHomePage.groovy file

  import geb.Page

  class GebishOrgHomePage extends Page {

   static at = { title == "Geb - Very Groovy Browser Automation" }

 static content = {
    manualsMenu { module(ManualsMenuModule) }
 }

}

Here is the ManualsMenuModule.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") }
 }
}

Here is the TheBookOfGebPage.groovy

import geb.Page

class TheBookOfGebPage extends Page {

static at = { title.startsWith("The Book Of Geb") }
}

Here is the 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>

`


回答1:


I had similar problems when just trying with x64 drivers. Every version > 0.14.0 shows this symptom (4 empty browser windows, 4 instances of geckodriver.exe which need to be killed manually). As soon as I reverted my project to 0.14.0, everything worked again like a charm, even with current FF Quantum 59.0.2 (64-bit).

This is not a solution, of course, but a workaround. If there is a corresponding ticket for Geckodriver I do not know. I have not checked yet.


Update: I am still using Selenium 3.0.1. Maybe this is why I cannot use never versions of Geckodriver because on the release page it says that for driver version 0.15 you need at least Selenium 3.3. But as you said you use Selenium 3.11, this should not be a problem. Even Geckodriver 0.19.0 only needs Selenium 3.5. But maybe your Maven setup is flawed and somehow it pulls in an older Selenium version. You could check this.



来源:https://stackoverflow.com/questions/49969902/geb-geckodriver-not-working-properly-launching-multiple-browser-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!