karma-runner / karma-webdriver-launcher

A plugin for Karma. Launch any browser with WebDriver.
MIT License
66 stars 40 forks source link

Not working with the docker image selenium/standalone-chrome:3.9 or newer #44

Open michaelzangl opened 4 years ago

michaelzangl commented 4 years ago

When using this driver to connect to selenium/standalone-chrome:3.9 or newer, one gets a confusing error message:

09 09 2020 13:25:20.208:DEBUG [WebDriver]: WebDriver config: {"remoteHost":true,"hostname":"localhost","port":4444}
09 09 2020 13:25:20.209:DEBUG [WebDriver]: Browser capabilities: {"platform":"ANY","testName":"Karma test","tags":[],"version":"","base":"WebDriver","browserName":"chrome"}
09 09 2020 13:25:21.558:DEBUG [WebDriver]: Session ID: undefined
09 09 2020 13:25:21.588:ERROR [WebDriver]: WebDriver command failed { spec:
   { platform: 'ANY',
     testName: 'Karma test',
     tags: [],
     version: '',
     base: 'WebDriver',
     browserName: 'chrome' },
  error:
   {"message":"[get(\"http://ip-of-host-running-karma-tests:9876/?id=99564073\")] Error response status: 6 Selenium error: No active session with ID url","status":6,"cause":{"sessionId":"url","value":{"error":"invalid session id","message":"No active session with ID url","stacktrace":""},"status":6}} }

Tried to use several configs, the session id is always undefined. Might be a bug somewhere in the wd dependency.

Workaround: Use the selenium/standalone-chrome:3.8 docker image.

joeyparrish commented 4 years ago

Could this be an issue with the docker image instead? Have you tried the debugging instructions at https://github.com/SeleniumHQ/docker-selenium#troubleshooting ?

michaelzangl commented 4 years ago

Hi. I suspect this is a problem with the JS library wd and how wd attempts to access the selenium hub instance. We have no problems accessing that container the normal selenium Java library. The first issue is that sessionId is null =>

I currently found no way to inspect the HTTP traffic wd sends to the selenium endpoint.

If I interpret it correclty, the issue might be around that line in wd: jsonData.value ? jsonData.value.sessionId : false; According to the specs, there should be no .value and no .status, so it falls back to the old method.

The error message is confusing, the error handling in karma-webdriver-launcher is just missing.

kisdaniel commented 2 years ago

I get this error in selenoid when the appropriate selenoid image (selenoid/vnc_chrome:xxx) is not pulled manually in docker.