Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make it work with RemoteWebDriver and Docker #349

Closed
vmassol opened this issue Sep 11, 2020 · 5 comments
Closed

Cannot make it work with RemoteWebDriver and Docker #349

vmassol opened this issue Sep 11, 2020 · 5 comments

Comments

@vmassol
Copy link

vmassol commented Sep 11, 2020

Hi there,

I admit that the issue could well be outside of the jasmine plugin but I cannot figure it and I'd need some hep, at least to debug it.

So I'm trying to do the following:

  • Start Chrome headless + webdriver by using a docker image. Specifically I'm running docker run --privileged -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug.
  • Configure the jasmine plugin to use it, by configuring it to use a RemoteWebDriver driver class as follows:
            <webDriverClassName>org.openqa.selenium.remote.RemoteWebDriver</webDriverClassName>
            <webDriverCapabilities>
              <capability>
                <name>browserName</name>
                <value>chrome</value>
              </capability>
              <capability>
                <name>chromeOptions</name>
                <value implementation="org.openqa.selenium.chrome.ChromeOptions" >
                  <args>
                    <value>--headless</value>
                    <value>--disable-gpu</value>
                    <value>--no-sandbox</value>
                  </args>
                </value>
              </capability>
            </webDriverCapabilities>
    

The docker image starts well and I can see that jasmine, through WebDriverManager, succeeds in creating an instance of the webdriver class:

$ docker run --privileged -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug
2020-09-11 14:39:23,515 INFO Included extra file "/etc/supervisor/conf.d/selenium-debug.conf" during parsing
2020-09-11 14:39:23,516 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2020-09-11 14:39:23,520 INFO supervisord started with pid 7
2020-09-11 14:39:24,524 INFO spawned: 'xvfb' with pid 10
2020-09-11 14:39:24,531 INFO spawned: 'fluxbox' with pid 11
2020-09-11 14:39:24,536 INFO spawned: 'vnc' with pid 14
2020-09-11 14:39:24,539 INFO spawned: 'selenium-standalone' with pid 15
2020-09-11 14:39:24,667 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-09-11 14:39:24,667 INFO success: fluxbox entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-09-11 14:39:24,667 INFO success: vnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-09-11 14:39:24,668 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
14:39:25.188 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
14:39:25.417 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-09-11 14:39:25.531:INFO::main: Logging initialized @967ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:39:26.100 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
14:39:26.329 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444

<-- this part below comes from the jasmine interaction -->
14:39:47.567 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "goog:chromeOptions": {
    "args": [
      "--headless",
      "--disable-gpu",
      "--no-sandbox"
    ],
    "extensions": [
    ]
  }
}
14:39:47.570 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 85.0.4183.83 (94abc2237ae0c9a4cb5f035431c8adfb94324633-refs/branch-heads/4183@{#1658}) on port 23796
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1599835187.660][SEVERE]: bind() failed: Cannot assign requested address (99)
14:39:49.160 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
14:39:49.225 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session d029a02e5986d3dbdbafb309fd386888 (org.openqa.selenium.chrome.ChromeDriverService)
14:39:49.639 INFO [ActiveSessions$1.onStop] - Removing session d029a02e5986d3dbdbafb309fd386888 (org.openqa.selenium.chrome.ChromeDriverService)

And on the jasmine side (client side):

[ERROR] Failed to execute goal com.github.searls:jasmine-maven-plugin:3.0-alpha-01:test (default) on project application-ckeditor-plugins: The jasmine-maven-plugin encountered an exception:: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
[ERROR]   (Session info: headless chrome=85.0.4183.83)
[ERROR] Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
[ERROR] System info: host: 'vmassol', ip: 'fe80:0:0:0:1cfc:9b5e:d9d4:c96d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '1.8.0_202'
[ERROR] Driver info: org.openqa.selenium.remote.RemoteWebDriver
[ERROR] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.83 (94abc2237ae0c..., userDataDir: /tmp/.com.google.Chrome.Q8BQWD}, goog:chromeOptions: {debuggerAddress: localhost:33967}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: d029a02e5986d3dbdbafb309fd3...}
[ERROR] Session ID: d029a02e5986d3dbdbafb309fd386888
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.searls:jasmine-maven-plugin:3.0-alpha-01:test (default) on project application-ckeditor-plugins: The jasmine-maven-plugin encountered an exception:
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: The jasmine-maven-plugin encountered an exception:
    at com.github.searls.jasmine.mojo.AbstractJasmineMojo.execute (AbstractJasmineMojo.java:360)
    at com.github.searls.jasmine.mojo.TestMojo.execute (TestMojo.java:213)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.RuntimeException: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: headless chrome=85.0.4183.83)
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'vmassol', ip: 'fe80:0:0:0:1cfc:9b5e:d9d4:c96d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '1.8.0_202'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.83 (94abc2237ae0c..., userDataDir: /tmp/.com.google.Chrome.Q8BQWD}, goog:chromeOptions: {debuggerAddress: localhost:33967}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: d029a02e5986d3dbdbafb309fd3...}
Session ID: d029a02e5986d3dbdbafb309fd386888
    at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute (SpecRunnerExecutor.java:80)
    at com.github.searls.jasmine.mojo.TestMojo.executeSpecs (TestMojo.java:247)
    at com.github.searls.jasmine.mojo.TestMojo.run (TestMojo.java:227)
    at com.github.searls.jasmine.mojo.AbstractJasmineMojo.execute (AbstractJasmineMojo.java:356)
    at com.github.searls.jasmine.mojo.TestMojo.execute (TestMojo.java:213)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: headless chrome=85.0.4183.83)
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'vmassol', ip: 'fe80:0:0:0:1cfc:9b5e:d9d4:c96d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '1.8.0_202'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.83 (94abc2237ae0c..., userDataDir: /tmp/.com.google.Chrome.Q8BQWD}, goog:chromeOptions: {debuggerAddress: localhost:33967}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: d029a02e5986d3dbdbafb309fd3...}
Session ID: d029a02e5986d3dbdbafb309fd386888
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException (W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.get (RemoteWebDriver.java:325)
    at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute (SpecRunnerExecutor.java:69)
    at com.github.searls.jasmine.mojo.TestMojo.executeSpecs (TestMojo.java:247)
    at com.github.searls.jasmine.mojo.TestMojo.run (TestMojo.java:227)
    at com.github.searls.jasmine.mojo.AbstractJasmineMojo.execute (AbstractJasmineMojo.java:356)
    at com.github.searls.jasmine.mojo.TestMojo.execute (TestMojo.java:213)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Some notes:

  • AFAIU [SEVERE]: bind() failed: Cannot assign requested address (99) is not a problem. It usually means that ipv6 is not enabled in docker but chrome falls back to listening to ipv4.
  • I'm failing to find some ways to get more details about org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED. All I can see from the stack trace is that it comes from the interaction with the webdriver at: driver.get(runnerUrl.toString()); (in SpecRunnerExecutor.java).

If you have any idea how to debug this, it would be awesome!

Thanks a lot

klieber added a commit to klieber/jasmine-maven-plugin that referenced this issue Sep 16, 2020
Example usage:

```xml
<plugin>
  <groupId>com.github.searls</groupId>
  <artifactId>jasmine-maven-plugin</artifactId>
  <version>${jasmine-maven-plugin.version}</version>
  <executions>
    <execution>
      <goals>
        <goal>test</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <serverHostname>${accessibleHostname}</serverHostname>
    <webDriverClassName>org.openqa.selenium.remote.RemoteWebDriver</webDriverClassName>
    <webDriverCapabilities>
      <webDriverCapability>
        <name>browserName</name>
        <value>chrome</value>
      </webDriverCapability>
      <webDriverCapability>
        <name>goog:chromeOptions</name>
        <value implementation="org.openqa.selenium.chrome.ChromeOptions">
          <headless>true</headless>
        </value>
      </webDriverCapability>
    </webDriverCapabilities>
  </configuration>
</plugin>
```

closes searls#234
closes searls#235
closes searls#349
@klieber
Copy link
Collaborator

klieber commented Sep 16, 2020

This will be fixed in the 3.0 release which should be coming soon. Usage will look like this:

<plugin>
  <groupId>com.github.searls</groupId>
  <artifactId>jasmine-maven-plugin</artifactId>
  <version>${jasmine-maven-plugin.version}</version>
  <executions>
    <execution>
      <goals>
        <goal>test</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <serverHostname>${accessibleHostname}</serverHostname>
    <webDriverClassName>org.openqa.selenium.remote.RemoteWebDriver</webDriverClassName>
    <webDriverCapabilities>
      <webDriverCapability>
        <name>browserName</name>
        <value>chrome</value>
      </webDriverCapability>
      <webDriverCapability>
        <name>goog:chromeOptions</name>
        <value implementation="org.openqa.selenium.chrome.ChromeOptions">
          <headless>true</headless>
        </value>
      </webDriverCapability>
    </webDriverCapabilities>
    <!-- If your remote server is not running at http://localhost:4444/wd/hub then you can use this parameter to configure the right location -->
    <!-- <remoteWebDriverUrl>http://localhost:4444/wd/hub</remoteWebDriverUrl> -->
  </configuration>
</plugin>

klieber added a commit to klieber/jasmine-maven-plugin that referenced this issue Sep 16, 2020
Example usage:

```xml
<plugin>
  <groupId>com.github.searls</groupId>
  <artifactId>jasmine-maven-plugin</artifactId>
  <version>${jasmine-maven-plugin.version}</version>
  <executions>
    <execution>
      <goals>
        <goal>test</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <serverHostname>${accessibleHostname}</serverHostname>
    <webDriverClassName>org.openqa.selenium.remote.RemoteWebDriver</webDriverClassName>
    <webDriverCapabilities>
      <webDriverCapability>
        <name>browserName</name>
        <value>chrome</value>
      </webDriverCapability>
      <webDriverCapability>
        <name>goog:chromeOptions</name>
        <value implementation="org.openqa.selenium.chrome.ChromeOptions">
          <headless>true</headless>
        </value>
      </webDriverCapability>
    </webDriverCapabilities>
    <!-- If your remote server is not running at http://localhost:4444/wd/hub then you can use this parameter to configure the right location -->
    <!-- <remoteWebDriverUrl>http://localhost:4444/wd/hub</remoteWebDriverUrl> -->
  </configuration>
</plugin>
```

closes searls#234
closes searls#235
closes searls#349
@vmassol
Copy link
Author

vmassol commented Sep 16, 2020

that's awesome, thanks a lot @klieber 👍

@vmassol
Copy link
Author

vmassol commented Sep 23, 2020

@klieber I've just noticed that you released 3.0-beta-01 (https://github.com/searls/jasmine-maven-plugin/releases). I've tested it and it still fails for me with the same error as before...

Here's what I have:

  • Remote Selenium started with `docker run --privileged -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug``
  • Jasmine plugin configured with:
        <plugin>
          <groupId>com.github.searls</groupId>
          <artifactId>jasmine-maven-plugin</artifactId>
          <!-- We want a more recent version of Jasmine because we want to use the (headless) Chrome driver. -->
          <version>3.0-beta-01</version>
          <executions>
            <execution>
              <goals>
                <goal>test</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
            <!-- jasmine-require-config.txt is filtered so we load it from the test output directory. -->
            <customRunnerConfiguration>
              ${project.build.testOutputDirectory}/jasmine-require-config.txt
            </customRunnerConfiguration>
            <preloadSources>
              <source>/webjars/require.js</source>
            </preloadSources>
            <jsSrcDir>${project.basedir}/src/main/resources</jsSrcDir>
            <timeout>10</timeout>
            <debug>true</debug>
            <serverHostname>localhost</serverHostname>
            <webDriverClassName>org.openqa.selenium.remote.RemoteWebDriver</webDriverClassName>
            <webDriverCapabilities>
              <webDriverCapability>
                <name>browserName</name>
                <value>chrome</value>
              </webDriverCapability>
              <webDriverCapability>
                <name>goog:chromeOptions</name>
                <value implementation="org.openqa.selenium.chrome.ChromeOptions">
                  <headless>true</headless>
                </value>
              </webDriverCapability>
            </webDriverCapabilities>
          </configuration>
        </plugin>
    

And I get:

  • On the client side (maven side):
[INFO] --- jasmine-maven-plugin:3.0-beta-01:test (default) @ application-ckeditor-plugins ---
[INFO] Logging initialized @14648ms to org.eclipse.jetty.util.log.Slf4jLog
[INFO] jetty-9.4.31.v20200723; built: 2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 1.8.0_202-b08
[INFO] Started o.e.j.s.h.ContextHandler@be6d228{/src,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,AVAILABLE}
[INFO] Started o.e.j.s.h.ContextHandler@60c96eb4{/spec,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,AVAILABLE}
[INFO] Started o.e.j.s.h.ContextHandler@7eee6c13{/,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,AVAILABLE}
[INFO] Started o.e.j.s.h.ContextHandler@2ae5bd34{/classpath,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,AVAILABLE}
[INFO] Started o.e.j.s.h.ContextHandler@7db791df{/webjars,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,AVAILABLE}
[INFO] Started ServerConnector@ce561cc{HTTP/1.1, (http/1.1)}{0.0.0.0:51933}
[INFO] Started @15336ms
[INFO] Executing Jasmine Specs
Sep 23, 2020 1:53:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[INFO] Stopped ServerConnector@ce561cc{HTTP/1.1, (http/1.1)}{0.0.0.0:0}
[INFO] Stopped o.e.j.s.h.ContextHandler@7db791df{/webjars,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,UNAVAILABLE}
[INFO] Stopped o.e.j.s.h.ContextHandler@2ae5bd34{/classpath,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,UNAVAILABLE}
[INFO] Stopped o.e.j.s.h.ContextHandler@7eee6c13{/,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,UNAVAILABLE}
[INFO] Stopped o.e.j.s.h.ContextHandler@60c96eb4{/spec,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,UNAVAILABLE}
[INFO] Stopped o.e.j.s.h.ContextHandler@be6d228{/src,file:///Users/vmassol/dev/xwiki/application-ckeditor/plugins/,UNAVAILABLE}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.043 s
[INFO] Finished at: 2020-09-23T13:53:32+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.searls:jasmine-maven-plugin:3.0-beta-01:test (default) on project application-ckeditor-plugins: The jasmine-maven-plugin encountered an exception:: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
[ERROR]   (Session info: headless chrome=85.0.4183.83)
[ERROR] Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
[ERROR] System info: host: 'vmassol', ip: 'fe80:0:0:0:1cfc:9b5e:d9d4:c96d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '1.8.0_202'
[ERROR] Driver info: org.openqa.selenium.remote.RemoteWebDriver
[ERROR] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.83 (94abc2237ae0c..., userDataDir: /tmp/.com.google.Chrome.k1DCqB}, goog:chromeOptions: {debuggerAddress: localhost:45677}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 7c3e2df9419401b5efe1a7e299b...}
[ERROR] Session ID: 7c3e2df9419401b5efe1a7e299b54a91
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.searls:jasmine-maven-plugin:3.0-beta-01:test (default) on project application-ckeditor-plugins: The jasmine-maven-plugin encountered an exception:
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
...
Caused by: org.apache.maven.plugin.MojoExecutionException: The jasmine-maven-plugin encountered an exception:
    at com.github.searls.jasmine.mojo.AbstractJasmineMojo.execute (AbstractJasmineMojo.java:374)
    at com.github.searls.jasmine.mojo.TestMojo.execute (TestMojo.java:215)
...
Caused by: java.lang.RuntimeException: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: headless chrome=85.0.4183.83)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'vmassol', ip: 'fe80:0:0:0:1cfc:9b5e:d9d4:c96d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '1.8.0_202'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.83 (94abc2237ae0c..., userDataDir: /tmp/.com.google.Chrome.k1DCqB}, goog:chromeOptions: {debuggerAddress: localhost:45677}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 7c3e2df9419401b5efe1a7e299b...}
Session ID: 7c3e2df9419401b5efe1a7e299b54a91
    at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute (SpecRunnerExecutor.java:80)
    at com.github.searls.jasmine.mojo.TestMojo.executeSpecs (TestMojo.java:249)
    at com.github.searls.jasmine.mojo.TestMojo.run (TestMojo.java:229)
    at com.github.searls.jasmine.mojo.AbstractJasmineMojo.execute (AbstractJasmineMojo.java:370)
    at com.github.searls.jasmine.mojo.TestMojo.execute (TestMojo.java:215)
...
Caused by: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: headless chrome=85.0.4183.83)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'vmassol', ip: 'fe80:0:0:0:1cfc:9b5e:d9d4:c96d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '1.8.0_202'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.83 (94abc2237ae0c..., userDataDir: /tmp/.com.google.Chrome.k1DCqB}, goog:chromeOptions: {debuggerAddress: localhost:45677}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 7c3e2df9419401b5efe1a7e299b...}
Session ID: 7c3e2df9419401b5efe1a7e299b54a91
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException (W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.get (RemoteWebDriver.java:277)
    at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute (SpecRunnerExecutor.java:69)
...
[ERROR] 

And on the selenium side (in the docker container):

2020-09-23 11:45:09,755 INFO Included extra file "/etc/supervisor/conf.d/selenium-debug.conf" during parsing
2020-09-23 11:45:09,755 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2020-09-23 11:45:09,759 INFO supervisord started with pid 8
2020-09-23 11:45:10,766 INFO spawned: 'xvfb' with pid 11
2020-09-23 11:45:10,769 INFO spawned: 'fluxbox' with pid 12
2020-09-23 11:45:10,770 INFO spawned: 'vnc' with pid 13
2020-09-23 11:45:10,772 INFO spawned: 'selenium-standalone' with pid 14
2020-09-23 11:45:11,115 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-09-23 11:45:11,115 INFO success: fluxbox entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-09-23 11:45:11,115 INFO success: vnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2020-09-23 11:45:11,115 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
11:45:11.507 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
11:45:11.649 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-09-23 11:45:11.746:INFO::main: Logging initialized @885ms to org.seleniumhq.jetty9.util.log.StdErrLog
11:45:12.107 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
11:45:12.216 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444

11:53:32.204 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome",
  "goog:chromeOptions": {
    "args": [
      "--headless",
      "--disable-gpu"
    ],
    "extensions": [
    ]
  }
}
11:53:32.204 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 85.0.4183.83 (94abc2237ae0c9a4cb5f035431c8adfb94324633-refs/branch-heads/4183@{#1658}) on port 7425
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1600862012.213][SEVERE]: bind() failed: Cannot assign requested address (99)
11:53:32.393 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
11:53:32.394 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 7c3e2df9419401b5efe1a7e299b54a91 (org.openqa.selenium.chrome.ChromeDriverService)
11:53:32.600 INFO [ActiveSessions$1.onStop] - Removing session 7c3e2df9419401b5efe1a7e299b54a91 (org.openqa.selenium.chrome.ChromeDriverService)

So the issue is still this Caused by: org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED error but I don't see what could be wrong. Not that since there are logs inside the container it means that jasmine is able to connect to the remote selenium server.

Would you have any idea of what could be wrong?

Thank you very much.

@vmassol
Copy link
Author

vmassol commented Oct 5, 2020

@klieber kind ping about the message above.

@surli
Copy link

surli commented Dec 4, 2020

Hi @klieber I reproduce the same issue as @vmassol. I've been able to put a breakpoint on this specific line: https://github.com/searls/jasmine-maven-plugin/blob/master/src/main/java/com/github/searls/jasmine/runner/SpecRunnerExecutor.java#L69 that's where the problem occurs: for some reason the command is not accepted and makes everything crashing.
What I don't understand is that apparently the port is randomly selected here, I can see on my breakpoint that the command is called with the following URL: http://localhost:44237 and apparently the port is set in https://github.com/searls/jasmine-maven-plugin/blob/master/src/main/java/com/github/searls/jasmine/mojo/TestMojo.java#L226. Wouldn't that explain the connection issue since I never opened such port on docker? Any other idea on what could cause the problem?

klieber added a commit to klieber/jasmine-maven-plugin that referenced this issue Aug 24, 2022
Example usage:

```xml
<plugin>
  <groupId>com.github.searls</groupId>
  <artifactId>jasmine-maven-plugin</artifactId>
  <version>${jasmine-maven-plugin.version}</version>
  <executions>
    <execution>
      <goals>
        <goal>test</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <serverHostname>${accessibleHostname}</serverHostname>
    <webDriverClassName>org.openqa.selenium.remote.RemoteWebDriver</webDriverClassName>
    <webDriverCapabilities>
      <webDriverCapability>
        <name>browserName</name>
        <value>chrome</value>
      </webDriverCapability>
      <webDriverCapability>
        <name>goog:chromeOptions</name>
        <value implementation="org.openqa.selenium.chrome.ChromeOptions">
          <headless>true</headless>
        </value>
      </webDriverCapability>
    </webDriverCapabilities>
    <!-- If your remote server is not running at http://localhost:4444/wd/hub then you can use this parameter to configure the right location -->
    <!-- <remoteWebDriverUrl>http://localhost:4444/wd/hub</remoteWebDriverUrl> -->
  </configuration>
</plugin>
```

closes searls#234
closes searls#235
closes searls#349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants