electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 229 forks source link

ChromeDriver did not start with Spectron 11.1.0 #648

Open TimTalis opened 4 years ago

hrishabhkumar commented 4 years ago

I am also getting same issue with electron 9

harrellbm commented 4 years ago

I am getting a similar issue but only in my CI environment. It is a very spastic bug that has been on and off since Electron 7/Spectron 9. Tests run fine locally, but as soon as they run in GitHub actions chromedriver will randomly decide to not start. It does not seem to be a consistent test that fails either but jumps around. The weird thing is that sometimes one or two test will fail but then if the test suite is rerun later everything will pass just fine.

The error that always gets thrown is this:

Error: ChromeDriver did not start within 5000ms 
    at /home/runner/work/Communication-Manager-Electron/Communication Manager-Electron/node_modules/spectron/lib/chrome-driver.js:63:25
    at Request._callback (/home/runner/work/Communication-Manager-Electron/Communication-Manager-Electron/node_modules/spectron/lib/chrome-driver.js:121:23)
    at self.callback (/home/runner/work/Communication-Manager-Electron/Communication-Manager-Electron/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.EventEmitter.emit (domain.js:482:12)
    at Request.onRequestError (/home/runner/work/Communication-Manager-Electron/Communication-Manager-Electron/node_modules/request/request.js:877:8)
    at ClientRequest.emit (events.js:315:20)
    at ClientRequest.EventEmitter.emit (domain.js:482:12)
    at Socket.socketErrorListener (_http_client.js:426:9)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:482:12)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I don't really know where to start with troubleshooting since its so irregular.

Update:

I didn't realize that I was still only on spectron 11. Updating to 11.1.0 crashed everything. But changed the errors being throw entirely. Now every test throws this:

 TypeError: app.client.click is not a function
      at Context.<anonymous> (test/test_index.js:598:22)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

I see that there are other issues more similar to this and will post this there.

dlqqq commented 4 years ago

Reproducible in the circleci/node:latest-browsers Docker image. Specifically, the error I receive is this:

  Application launch
    1) "before each" hook for "shows an initial window"

  0 passing (1s)
  1 failing

  1) Application launch
       "before each" hook for "shows an initial window":
     Error: Failed to create session.
unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)

Interestingly, I can start chromedriver just fine:

$ chromedriver --whitelisted-ips=
Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}) on port 9515
All remote connections are allowed. Use a whitelist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Which leads me to believe this has something to do with WebdriverIO.

twitharshil commented 4 years ago

This is happening with me as well. Any updates here?

jameskerr commented 4 years ago

Also experiencing this.

megahertz commented 4 years ago

I've spent hours for finding the reason. For me, the reason was got dependency of webdriver. I've downgraded it from 11.7.0 to 11.5.1 (by changing package-lock.json) and now it works fine.

adam-lynch commented 4 years ago

@megahertz could you explain a bit more how you did that? I've tried editing package-lock.json but npm install resets it

adam-lynch commented 4 years ago

OK I figured it out, but it didn't help for me at all. If anyone else wants to try, replace this in your package-lock.json:

        "got": {
          "version": "11.7.0",
          "resolved": "https://registry.npmjs.org/got/-/got-11.7.0.tgz",
          "integrity": "sha512-7en2XwH2MEqOsrK0xaKhbWibBoZqy+f1RSUoIeF1BLcnf+pyQdDsljWMfmOh+QKJwuvDIiKx38GtPh5wFdGGjg==",

... with:

        "got": {
          "version": "11.5.1",
          "resolved": "https://registry.npmjs.org/got/-/got-11.5.1.tgz",
          "integrity": "sha512-reQEZcEBMTGnujmQ+Wm97mJs/OK6INtO6HmLI+xt3+9CvnRwWjXutUvb2mqr+Ao4Lu05Rx6+udx9sOQAmExMxA==",

"got" is mentioned a few times but it seems that's the place that needs to be changed in order for npm install to grab the right version. I got the integrity value from https://registry.npmjs.org/got/11.5.1

vladimiry commented 4 years ago

@adam-lynch, npm install => npm ci. If someone runs yarn, there is resolutions package.json section for this purpose.

megahertz commented 4 years ago
    "webdriver": {
      "version": "6.5.0",
      "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-6.5.0.tgz",
      "integrity": "sha512-6iOll9TshD4+2J+em+bLshvM1uXtnotdZ+JaALqRLbkVswLRFU0pTVP1oug0e/IYwL7Me4Cafh9ugQ4PwPuOnA==",
      "dev": true,
      "requires": {
        "@wdio/config": "6.4.7",
        "@wdio/logger": "6.4.7",
        "@wdio/protocols": "6.3.6",
        "@wdio/utils": "6.5.0",
        "lodash.merge": "^4.6.1"
      },
      "dependencies": {
        ...
        "got": {
          "version": "11.5.1"
        },
        ...

npm i

after that, npm ls got should show version 11.5.1 for got, in my case:

├─┬ electron@9.3.1
│ └─┬ @electron/get@1.12.2
│   └── got@9.6.0 
└─┬ spectron@11.1.0
  └─┬ webdriverio@6.5.2
    └─┬ webdriver@6.5.0
      └── got@11.5.1 
jesusiglesias commented 4 years ago

@megahertz How did you find out that the problem was that dependency?

megahertz commented 4 years ago

@jesusiglesias I've traced until that place than replaced got by request (it works correctly), than tried got 11.5.1 instead of the latest

gilles-yvetot commented 3 years ago

I am also still seeing this in spectron v12 and v13

reaandrew commented 3 years ago

Double check there is not an instance of chromedriver already running. If you try and invoke chromedriver directly it will error if this is the case and it will give you the port number it is trying to bind to. Kill this existing process and try again, this is what the issue was with mine.