protractor/selenium “could not find chromedriver a

2019-03-08 10:12发布

I installed protractor following this tutorial and when i use webdriver-manager update it says:

selenium standalone is up to date.
chromedriver is up to date.

thou when i try to run the protractor tests, it says:

C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\local.dp.js:42
            throw new Error('Could not find chromedriver at ' +
                  ^
    Error: Could not find chromedriver at C:\Users\****\AppData\Roaming\npm\node_modules\protractor\selenium\chromedriver.exe
        at LocalDriverProvider.addDefaultBinaryLocs_ (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\local.dp.js:42:15)
        at LocalDriverProvider.setupEnv (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\local.dp.js:59:8)
        at Runner.run (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:308:31)
        at process.<anonymous> (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\runFromLauncher.js:32:14)
        at process.EventEmitter.emit (events.js:98:17)
        at handleMessage (child_process.js:318:10)
        at Pipe.channel.onread (child_process.js:345:11)
    [launcher] Runner Process Exited With Error Code: 8

I checked the local.dp.js and saw that it tried to load the chromedriver from ..\node_modules\protractor\selenium\chromedriver but there only was an empty zip file called chromedriver_2.9.

So i downloaded the chromedriver manually and copied it to this location, producing a new error:

C:\Users\****\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1549
      throw error;
            ^
Error: Server exited with 1
    at Error (<anonymous>)
    at ChildProcess.onServerExit (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:193:11)
    at ChildProcess.g (events.js:180:16)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:797:12)
[launcher] Runner Process Exited With Error Code: 8

Anyone any Ideas?

14条回答
祖国的老花朵
2楼-- · 2019-03-08 10:43

In my case it was the due to damaged chromedriver zip file.

I have done following things to resolve this problem.

  1. Downloaded chromedriver zip from ChromeDriver Download Page

  2. Extracted that zip file at "node_modules\protractor\selenium\" (i.e. Copied "chromedriver.exe" to this location)

Then it started working as expected. Hope this will help you.

查看更多
Evening l夕情丶
3楼-- · 2019-03-08 10:46

I followed that tutorial and had the same problem. The issue here was that you need to specify the path to your selenium jar and chrome driver exe in your protractor config file. Mine was installed globally in AppData folder so this is what mine protractor.confg.js file looks like:

exports.config = {

specs: [
    'test/e2e/**/*.js'
],

chromeDriver: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/chromedriver.exe',

seleniumServerJar: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/selenium-server-standalone-2.40.0.jar',

baseUrl: 'http://localhost:9000/'

};

That seemed to do the trick.

查看更多
看我几分像从前
4楼-- · 2019-03-08 10:48

On mac osx, change the version in package.json for protractor to "*", remove node_modules, and install again.

查看更多
一纸荒年 Trace。
5楼-- · 2019-03-08 10:52

After looking around for a while, I noticed that the package.json file included in the angular phonecat repo defines a update-webdriver task.

Running that task (with npm run update-webdriver) fixed protractor for me.

查看更多
疯言疯语
6楼-- · 2019-03-08 10:52

For me the npm install and npm run update-webdriver commands just kept downloading the corrupt Chromedriver_x.xx.zip file. So I tried running webdriver-manager update, and it worked.

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-03-08 10:55

Jeez, so many answers...

On the Mac, this worked for me:

$ npm install chromedriver
$ ln -sf ~/angular-phonecat/node_modules/chromedriver/bin/chromedriver node_modules/protractor/selenium/chromedriver.exe

There's GOT to be a better way of fixing it but at least this let me move on.

查看更多
登录 后发表回答