45

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?

Andresch Serj
  • 35,217
  • 15
  • 59
  • 101
  • i tried downloading chromedriver and putting it to the ..\node_modules\protractor\selenium\chromedriver.exe directly and it produced a new error – Andresch Serj Mar 05 '14 at 09:50

14 Answers14

67

I was facing this error too and by the time I read the tutorial, it did not cover how to install protractor and the webdriver as local dependencies to your project (which are located in ./node_modules).

If this is what you prefer (probably because you might want to use grunt-protractor-runner and run your test later in a continuous build manner as I neede) instead of installing it globally, this solution worked for me:

  1. Install protractor:

npm install protractor --save-dev

  1. Install selenium and the webdrivers with the webdriver-manager by running:

./node_modules/protractor/bin/webdriver-manager update

After calling this command have a look at ./node_modules/protractor and it subfolders to verify it. A folder called selenium with the chromedriver in should be available in it.

Note that as protractor was not installed as "global", calling it from the command line will result in a "commnad not found" error. You can run it instead with this command: ./node_modules/protractor/bin/protractor

Additionaly, it might be a good idea to add a script definition to your package.json, so that next time you install all your dependencies from zero, npm setup the webdrivers automaticaly. For that add this to your package.json file: "scripts": { "postinstall": "./node_modules/protractor/bin/webdriver-manager update" }

Hope this helps you further...

omgwtflol
  • 3
  • 2
stitakis
  • 891
  • 1
  • 7
  • 7
  • 2
    This answer actually solves the problem in a sane way. Thanks! – Adam McCormick May 27 '15 at 22:17
  • Worked for Windows 8.1 Enterprise. Thanks a lot! – Juri Sinitson Jun 10 '15 at 20:26
  • for me, it was needed just to run: `./node_modules/protractor/bin/webdriver-manager update`. awesome. thank you – ebragaparah Jan 21 '17 at 22:41
  • I have Chrome browser version 80 and I executed the **webdriver-manager update** but it thrown the error like *Could not find chromedriver at* I checked the node_modules/Web-driver Manager/Selenium but it does not have the relevant chrome driver version for browser version 80. Instead it had the chrome driver like 78,79 only – Ashok kumar Ganesan Mar 05 '20 at 07:17
27

If you are behind a proxy then try setting proxy first and then run webdriver update:

npm config set proxy http://<proxy.com>:port

webdriver-manager update
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Sneh Tripathi
  • 430
  • 4
  • 14
24

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.

Chester Rivas
  • 692
  • 7
  • 16
  • Also important to note I'm running protractor through Grunt, which runs with a connect task on port 9000. Hence the reason I've specified 9000 in my config. – Chester Rivas Apr 01 '14 at 16:17
  • chromeDriver: 'C:/Users//AppData/Roaming/npm/node_modules/protractor/selenium/chromedriver.exe', This part alone did it for me. I had previously installed (npm install -g protractor) globally and I wasn't able to run a gulp task from a specific directory. Thank you Chester. – VSO Aug 12 '15 at 00:14
  • 1
    It's a bit risky to add absolute paths when you are working with a team. For me the answer by @stitakis (running a webdriver-manager update) did the trick. – Micros Dec 15 '15 at 10:19
13

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.

bronson
  • 5,612
  • 3
  • 31
  • 18
  • 1
    Adding this to package.json will allow `npm install` to take care of it: `"postinstall": "echo -n $NODE_ENV | grep -v 'production' && ./node_modules/protractor/bin/webdriver-manager update || echo 'will NOT run webdriver install or update in production only'"` – pulkitsinghal Aug 27 '14 at 07:30
  • The zip file was always corrupted when I downloaded it. I'm not behind a proxy, so I'm not sure the problem. But I was able to get it to work with this process though running "npm run protractor" downloads chromedriver and places the executable in node_modules/chromedriver/lib/chromedriver/, so I linked it to there instead of the bin/ directory. When I did npm install chromedriver it just put a 398-byte stub in the bin/ directory. – bmacnaughton Apr 26 '15 at 14:47
7

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.

turtlemonvh
  • 9,149
  • 6
  • 47
  • 53
4

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
Sean Aitken
  • 1,177
  • 1
  • 11
  • 23
3

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.

Yuvraj Patil
  • 7,944
  • 5
  • 56
  • 56
3

I encountered similar issue when I followed angular's tutorial:

https://docs.angularjs.org/tutorial/step_03

and checked out the code accordingly:

git checkout -f step-3

Within angular-phonecat/package.json devDependencies, the protractor version is "~1.0.0", which caused npm always download a corrupted file:

angular-phonecat/node_modules/protractor/selenium/chromedriver_2.10.zip

Because the above zip file can't be opened properly, so below error exists:

/Users/karlli/dev/projects/angular-phonecat/node_modules/protractor/node_modules/adm-zip/zipFile.js:66 throw Utils.Errors.INVALID_FORMAT; ^ Invalid or unsupported zip format. No END header found

There are 2 solutions:

  1. symbol link the correct one instead

ln -sf ~/dev/projects/angular-phonecat/node_modules/chromedriver/bin/chromedriver node_modules/protractor/selenium/chromedriver.exe

Thanks @bronson :-)

  1. upgrade protractor's dependency version After several tests, I found the minimal workable version is 1.1.0.

angular-phonecat/package.json

"devDependencies": {
    "karma": "^0.12.16",
    "karma-chrome-launcher": "^0.1.4",
    "karma-jasmine": "^0.1.5",
    "protractor": "~1.1.0",
    "http-server": "^0.6.1",
    "tmp": "0.0.23",
    "bower": "^1.3.1",
    "shelljs": "^0.2.6"
},
karl li
  • 1,316
  • 15
  • 19
2

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
eflat
  • 919
  • 3
  • 13
  • 34
1

If on Windows, you may need to set an HTTP_PROXY environment variable. Try these steps in your command prompt, assuming your proxy server is http://proxy.you.com:8080.

  1. SETX HTTP_PROXY http://proxy.you.com:8080 (It should return SUCCESS: Specified value was saved. You can also do this in System Properties...Advanced...Environment Variables)
  2. Close your command prompt window and reopen. (This ensures your new environment variable will be used in your session.)
  3. Now run your command: webdriver-manager update
James Lawruk
  • 30,112
  • 19
  • 130
  • 137
  • The proxy is already defined using the `--proxy=http:///` Parameter as defined in the Answer given by @CleverCoder. Thanks thou. – Andresch Serj Feb 10 '15 at 08:47
1

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

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
0

The standalone selenium file was corrupt so i had to overwrite it, copying it into the folder directly.

C:/Users/****/AppData/Roaming/npm/node_modules/protractor/selenium/

Also i had to rename the chromedriver so it is actually called "chromedriver" and not "chromedriver.exe".

C:/Users/****/AppData/Roaming/npm/node_modules/protractor/selenium/chromedriver

This partially happened because i did not set the proxy in webdriver. You can see the Solution for this in the accepted answer.

Community
  • 1
  • 1
Andresch Serj
  • 35,217
  • 15
  • 59
  • 101
0

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.

Yhnert
  • 9
  • 2
-3

Just add the "preprotractor":" npm install chromedriver" to your package.json

That will down load the latest one all the time.