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:56

The Chrome driver can exist in any location, but the protractor runner seems to expect it to be in the location where it would exist if you installed it through "webdriver-manager". Thus, it can be installed with "npm install chromedriver", which will place it in a different location, such as: /usr/local/lib/node_modules/chromedriver/lib/chromedriver/chromedriver

In this case, the config file will need to be set to look in this location, but there is likelt a simpler solution...

If webdriver-manager fails to download either the chromedriver or selenium-standalone, there will be 0-byte files in the default location, which will cause this error. Unfortunately, this can happen with proxy related issues. Once the corrupt files are there, the update check process thinks everything is up-to-date, but it's not.

Also, the proxy configuration for webdriver-manager is different than npm. For webdriver-manager, the syntax to do an update would be:

sudo webdriver-manager update --proxy=http://<your proxy server>/

Clearing out the 0-byte files and re-running this update command should replace the files with their correct data. The location on my machine for these files is:

/usr/local/lib/node_modules/protractor/selenium
查看更多
看我几分像从前
3楼-- · 2019-03-08 10:56

On windows, I was having trouble with a project that ran fine on my mac. The command that finally got it done for me was:

node node_modules\protractor\bin\webdriver-manager update
查看更多
登录 后发表回答