webdriverio/webdriverio

'devtools' protocol: Popup win closes itself: getWindowHandles() hangs, 100% CPU

Open

#5,241 opened on Apr 9, 2020

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (1,793 forks)batch import
help wanted

Repository metrics

Stars
 (6,029 stars)
PR merge metrics
 (Avg merge 15d 15h) (48 merged PRs in 30d)

Description

Environment (please complete the following information):

  • WebdriverIO version: 6.0.14
  • Mode: WDIO Testrunner: ./node_modules/.bin/wdio
  • If WDIO Testrunner, running sync/async: sync
  • Node.js version: nodejs --version —> v12.16.2
  • NPM version: npm --version —> 6.13.4
  • Browser name and version: Chrome, Version 81.0.4044.92 (Official Build) (64-bit)
  • Platform name and version: Ubuntu 16.04.6 LTS
  • Additional wdio packages used (if applicable): My package.json:
{
  "author": "Magnus Lindberg",
  "name": "",
  "version": "0.0.1",
  "license": "",
  "engines": {
    "node": ">= 12.16.0"
  },
  "dependencies": {},
  "devDependencies": {
    "@wdio/cli": "^6.0.9",
    "@wdio/devtools-service": "^6.0.8",
    "@wdio/dot-reporter": "^6.0.8",
    "@wdio/firefox-profile-service": "^6.0.8",
    "@wdio/local-runner": "^6.0.9",
    "@wdio/mocha-framework": "^6.0.13",
    "@wdio/sync": "^6.0.8",
    "chromedriver": "^80.0.2",
    "http-server": "^0.11.1",
    "wdio-chromedriver-service": "^6.0.1"
  }
}

Config of WebdriverIO My wdio.conf.js: (it's just a default generated file, + path to the ... test.js)

exports.config = {
    runner: 'local',
    specs: [ './wdio-get-win-handles-self-closing-window.test.js' ],
    exclude: [],
    maxInstances: 10,
    capabilities: [{ maxInstances: 5, browserName: 'chrome' }],
    logLevel: 'trace', // trace debug info warn error silent
    bail: 0,
    baseUrl: 'http://localhost',
    waitforTimeout: 10000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,
    services: ['devtools'], // 'chromedriver' works though
    framework: 'mocha',
    reporters: ['dot'],
    mochaOpts: { ui: 'bdd', timeout: 60000 },
}

Describe the bug

A 2nd window opens (say, a login popup). WebdriverIO switches to this window. This 2nd window closes itself (say, after the user has logged in).

Thereaftter, the next call to browser.getWindowHandles() never returns — instead it pegs the CPU at 100%, and the node process won't exit, kill PID won't work, needs: kill -9 PID.

To Reproduce

Copy-paste into a new directory package.json, wdio.conf.js from above, plus the following *.html files and .js test file:

https://gist.github.com/kajmagnus/75f091bb12be830e81dcba246c2634da

Then: npm install. Then: ./node_modules/.bin/http-server -p8080 ./ — a static file server on port 8080. Then: ./node_modules/.bin/wdio wdio.conf.js — to run the test.

When the 2nd window closes, notice how the log messages from the while loop, stop abruptly — a request to browser.getWindowHandles() has somehow hanged.

Look at your CPU: A node process on my laptop now is 100%, needs kill -9.

Expected behavior

browser.getWindowHandles() should return 1 handle, not block.

Log

https://gist.github.com/kajmagnus/2b7f4e03f4adb06678d369ef5e97252b

Additional context

I might be one of the first people upgrading to WebdriverIO v6 and trying out the service: ['devtools']? (it was released just a few days or a week ago)

Contributor guide