0
votes

I've been trying to setup Protractor on Visual Studio Team Services and currently I'm having a build run a .bat file to start my protractor test.

When the build runs, it gives me an error message saying Could not find Chrome binary, and gives me a file location that doesn't exist on my directory.

Error trace-back:

2017-05-25T20:43:49.3521640Z ##[section]Starting: Run script protractor.bat
2017-05-25T20:43:49.3521640Z
===========================================================================
2017-05-25T20:43:49.3521640Z Task         : Batch Script
2017-05-25T20:43:49.3521640Z Description  : Run a windows cmd or bat script and optionally allow it to change the environment
2017-05-25T20:43:49.3521640Z Version      : 1.1.3
2017-05-25T20:43:49.3521640Z Author       : Microsoft Corporation
2017-05-25T20:43:49.3521640Z Help         : [More Information]
(https://go.microsoft.com/fwlink/?LinkID=613733)
2017-05-25T20:43:49.3521640Z     
============================================================================
2017-05-25T20:43:49.3601629Z ##[command]d:\a\1\s\protractor.bat 
2017-05-25T20:43:49.3761643Z 
2017-05-25T20:43:49.3761643Z d:\a\1\s>cd .\e2e 
2017-05-25T20:43:49.3761643Z 
2017-05-25T20:43:49.3761643Z d:\a\1\s\E2E>protractor conf.js 
2017-05-25T20:43:50.8302366Z [20:43:50] I/direct - Using ChromeDriver directly...
2017-05-25T20:43:50.8342360Z [20:43:50] I/launcher - Running 1 instances of WebDriver
2017-05-25T20:43:50.8342360Z [20:43:50] E/direct - Error code: 135
2017-05-25T20:43:50.8342360Z [20:43:50] E/direct - Error message: Could not find chromedriver at C:\NPM\Modules\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.25.exe
2017-05-25T20:43:50.8342360Z [20:43:50] E/direct - Error: Could not find chromedriver at C:\NPM\Modules\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.25.exe
2017-05-25T20:43:50.8342360Z     at Direct.getNewDriver (C:\NPM\Modules\node_modules\protractor\built\driverProviders\direct.js:65:27)
2017-05-25T20:43:50.8342360Z     at Runner.createBrowser (C:\NPM\Modules\node_modules\protractor\built\runner.js:197:43)
2017-05-25T20:43:50.8342360Z     at C:\NPM\Modules\node_modules\protractor\built\runner.js:276:30
2017-05-25T20:43:50.8342360Z     at _fulfilled (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:834:54)
2017-05-25T20:43:50.8342360Z     at self.promiseDispatch.done (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:863:30)
2017-05-25T20:43:50.8342360Z     at Promise.promise.promiseDispatch (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:796:13)
2017-05-25T20:43:50.8342360Z     at C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:556:49
2017-05-25T20:43:50.8342360Z     at runSingle (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:137:13)
2017-05-25T20:43:50.8342360Z     at flush (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:125:13)
2017-05-25T20:43:50.8342360Z     at _combinedTickCallback (internal/process/next_tick.js:67:7)
2017-05-25T20:43:50.8342360Z [20:43:50] E/launcher - Process exited with error code 135
2017-05-25T20:43:50.8552361Z ##[error]Process completed with exit code 135.
2017-05-25T20:43:50.8582364Z ##[section]Finishing: Run script protractor.bat

When I install Chromedriver on the build it installs it to a different file location: d:\a\1\s\node_modules\chromedriver\lib\chromedriver\chromedriver.exe

The test runs fine locally but doesn't work when I commit it to VSTS.

Is there anyway to make it so that chromedriver is installed in a different file location, or have Selenium look in a different place for chromedriver?

Thanks

3

3 Answers

0
votes

Put the relative path to the ChromeDriver executable in conf.js. This is well-documented.

0
votes

Use webdriver-manager package that comes with protractor - it can download any version of any binary that you want - https://www.npmjs.com/package/webdriver-manager

So it ends up with running webdriver-manager update before starting protractor tests (just make sure that if you are running locally installed protractor - you also update using locally installed webdriver-manager)

0
votes

First, based on the log, you are using Hosted Build agent that running as service, but the test need to be interact with UI, so you can’t to do Protractor test with Chrome on Hosted Build agent.

You can refer to this way to set up a private build agent on your machine: Deploy an agent on Windows

Secondly, you can refer to these steps to install chromedriver:

  1. Add Npm task (npm command: install; arguments: -g protractor)
  2. Add Command Line task (Tool: webdriver-manager; Arguments: update --versions.chrome 2.25)