Installing Protractor with npm in windows environment behind a proxy

Installing Protractor npm windows environment behind proxy
In this post we going to assume that you know what is Node, npm, etc so we don’t going to explain this.

Installing Protractor npm windows environment behind proxy

First we need to install or update NodeJs (npm comes with node now), you can click here to get the latest version.

We need to setup the npm to work behind a proxy so we can run protractor:

Run this commands in a console, for http and https

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

 

If you have to set username and password:

http://username:password@proxy.company.com:8080

if your password have an @ then surround it in quotes

http://"username:your@password"@proxy.company.com:8080

To reset proxy for npm:

npm config rm proxy
npm config rm https-proxy

To get the proxy settings for npm:

npm config get proxy
npm config get https-proxy

Quick notes to Setup Protractor

Use npm to install Protractor globally with:

npm install -g protractor

This will install two command line tools, protractor and
webdriver-manager. Try running
protractor --version to make sure it’s working.

The webdriver-manager is a helper tool to easily get an
instance of a Selenium Server running. Use it to download the necessary
binaries with:

webdriver-manager update

Now start up a server with:

webdriver-manager start

This will start up a Selenium Server and will output a bunch of info
logs. Your Protractor test will send requests to this server to control
a local browser.

 

Configuration

Create a file called protractor-conf.js in the test directory and add the following configuration to it.

The Selenium webdriver has the ability to execute tests against multiple browsers concurrently, making cross-browser testing easy. Protractor has a sample config file available with all the configuration options.

If you installed Protractor locally, be sure to set the seleniumServerJar and chromeDriver options with the location of these files.

exports.config = {
// location of the Selenium JAR file and chromedriver, use these if you installed protractor locally
// seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.40.0.jar',
// chromeDriver: '../node_modules/protractor/selenium/chromedriver',// location of your E2E test specs

specs: [
  '../test/e2e/*.js'
],// configure multiple browsers to run tests
multiCapabilities: [{
'browserName': 'firefox'
}, {
'browserName': 'chrome'
}],// or configure a single browser

/*
  capabilities: {
   'browserName': 'chrome'
 }
  */
// url where your app is running, relative URLs are prepending with this URL
baseUrl: 'http://localhost:9000/',


// testing framework, jasmine is the default</i>
framework: 'jasmine'
};

Notice that the baseUrl does not determine the location of your app. It just determines relative URLs. If you call browser.get(‘/’) in your Protractor tests, this will redirect to your baseUrl.

Hope this was helpful 😉