goosewobbler / wdio-electron-service-example

Minimal electron app providing a working example of testing using `wdio-electron-service`.
5 stars 4 forks source link

ChromeDriver does not exit at the end of tests #21

Closed troppoli closed 1 year ago

troppoli commented 2 years ago

I'm on windows 10, node 14.9.3.

You cannot run

npm run test

twice because the chomedriver process does not exit. You have to manually kill the process. I was experiencing this in the project I'm migrating to wdio and wdio-electron-servic. I'm not sure if it's a configuration problem or a wdio-electron-service issue.

PS C:\gitlab\wdio-electron-service-example> npm run test

> wdio-electron-service-example@1.0.0 test C:\gitlab\wdio-electron-service-example
> wdio run ./wdio.conf.js || (cat ./wdio-logs/wdio-0-0.log && cat ./wdio-logs/wdio-chromedriver.log && exit 1)

Execution of 4 workers started at 2022-07-19T16:42:16.574Z

SevereServiceError in "onPrepare"
SevereServiceError: 
A service failed in the 'onPrepare' hook
SevereServiceError: Couldn't start Chromedriver: timeout
Please check if port 9519 is in use!
    at ChromeDriverLauncher.onPrepare (C:\gitlab\wdio-electron-service-example\node_modules\wdio-chromedriver-service\build\launcher.js:91:13)       
    at async C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\utils.js:38:17
    at async Promise.all (index 0)
    at async Launcher.run (C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\launcher.js:86:13)

Stopping runner...
    at C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\utils.js:54:35
    at async Launcher.run (C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\launcher.js:86:13)
HookError [SevereServiceError]: 
A service failed in the 'onPrepare' hook
SevereServiceError: Couldn't start Chromedriver: timeout
Please check if port 9519 is in use!
    at ChromeDriverLauncher.onPrepare (C:\gitlab\wdio-electron-service-example\node_modules\wdio-chromedriver-service\build\launcher.js:91:13)       
    at async C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\utils.js:38:17
    at async Promise.all (index 0)
    at async Launcher.run (C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\launcher.js:86:13)

Stopping runner...
    at C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\utils.js:54:35
    at async Launcher.run (C:\gitlab\wdio-electron-service-example\node_modules\@wdio\cli\build\launcher.js:86:13) {
  origin: 'onPrepare'
}
'cat' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wdio-electron-service-example@1.0.0 test: `wdio run ./wdio.conf.js || (cat ./wdio-logs/wdio-0-0.log && cat ./wdio-logs/wdio-chromedriver.log && exit 1)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wdio-electron-service-example@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\stroppoli\AppData\Roaming\npm-cache\_logs\2022-07-19T16_42_26_923Z-debug.log
troppoli commented 2 years ago

I ended up hacking in a onComplete in my wdio config

onComplete: function(exitCode, config, capabilities, results) {
    // we should not have to do this, and the ts types don't jive with the doc above about promises.
    simpleExec('START /wait taskkill /f /im chromedriver.exe')
}
goosewobbler commented 1 year ago

Closing in favour of https://github.com/webdriverio-community/wdio-electron-service/issues/50 as this repo is being moved into wdio-electron-service.