Friday, May 1, 2015

Protractor on PhantomJS                                                                             


Install phantomJs using npm

First step is to install phanmJs

> npm install -g phantomjs

Go to npm location
In this step move to the NPM_LOCATION(folder where npm is installed at your system.

check the path of phantomJs.It should be

"NPM_LOCATION\node_modules\phantomjs\lib\phantom\phantomjs.exe


Change  in conf.js


// conf.js  in windows
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['specs.js'],
  capabilities: {
    'browserName': 'phantomjs' ,
    'phantomjs.binary.path': 'NPM_LOCATION/npm/node_modules/phantomjs/lib/phantom/phantomjs.exe'
    }

// spec.js
describe('Protractor Demo App', function() {
  it('should have a title', function() {
    browser.get('http://juliemr.github.io/protractor-demo/');
    expect(browser.getTitle()).toEqual('Super Calculator');
  });
}); 

Now run   protractor conf.js

Make sure that the path for phantomjs.binary.path always should be in  above format or for windows system  use  xxx\\yyy\\zzz\\

Note: Make sure you restart server by -->webdriver-manager start

Internet Explorer on protractor                                                                         


Update web manager for IE

First step is to update the ie webdriver using webdriver manager.Open command prompt and run the command given below

> webdriver-manager update --ie

Go to npm location
In this step move to the NPM_LOCATION(folder where npm is installed at your system.
Move to the following path "NPM_LOCATION\node_modules\protractor\selenium"
At this location check that IEDriverServer.exe is present or not.


Change for IE in conf.js


// conf.js
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['specs.js'],
  capabilities: {
    'browserName': 'internet explorer' // conf for internet explorer     }
}

// spec.js
describe('Protractor Demo App', function() {
  it('should have a title', function() {
    browser.get('http://juliemr.github.io/protractor-demo/');
    expect(browser.getTitle()).toEqual('Super Calculator');
  });
}); 

Now run   protractor conf.js

Note: Make sure you restart server by -->webdriver-manager start