How to start with protractor


Today we will see how to start up with protractor for your angularjs projects..

Prerequisites are nodejs and jasmine.

You can work with Jasmine and Protractor combination for end to end testing..similarly for unit testing you can work with jasmine and karma

Follow the steps from protractor guide

Now create a folder like end-end-testing like that and create the following files..

1. protractor.conf.js

exports.config = {

specs: [
// ‘./end-end-testing/**/*.js’

baseUrl: ‘http://localhost:8080/’,
capabilities: {
‘browserName’: ‘firefox’,
‘binary’: ‘C:/Program Files (x86)/Mozilla Firefox/firefox.exe’


describe(‘project homepage’, function() {

browser.driver.manage().window().setSize(400, 600);
var ptor = protractor.getInstance();
it(‘Page description.’, function() {

toEqual(‘element_id description.’); // This is Correct!
}); // end of it() page description
it(‘Contact page’, function() {

element(‘Name’)).sendKeys(‘Your Name’); //name filling in textbox

element(‘zipcode’)).sendKeys(‘524121); // text box filling

ptor.findElement(protractor.By.css(‘option[value=”1″]’)).click(); //select option set
element(‘someid’)).all(by.tagName(‘md-radio-button’)).get(1).click(); //radio button set
ptor.selectOption = selectOption.bind(ptor);
ptor.selectOption(‘select_id_country’), ‘India’); //set select id alternative

// button click code

}); // end of it() – contact page

}); // end of describe

If you want to run only one module say contact page it()..then comment browser.get(‘https://application-url’); in describe function and do as follows:

iit(‘Contact page’, function() { //have iit instead of it

browser.get(‘https://application-url/contact-page’); //add this browser.get method for that page alone..

element(‘Name’)).sendKeys(‘Your Name’); //name filling in textbox


How to run??

just go to end-end testing folder where you have protractor.conf.js and responsive_spec.js

then type ‘protractor protractor.conf.js’


The browser variable is a wrapper around the WebDriver instance. We use the browser variable for any navigation or for grabbing any information off the page.

We can use the browser variable to navigate to a page using the get() function:




If protractor wont run you may have to follow the set up of selenium drivers as shown below..

set path=%path%;.;C:\Program Files (x86)\Java\jre7\bin;
set path=%path%;.;C:\Users\userid\AppData\Roaming\npm;

npm install -g protractor

webdriver-manager update — dont run this command initially, copy 2 jars(below url links downloaded files) from path and paste it in Users/Appdata/Roaming/npm/node_modules/protractor/selenium)

webdriver-manager start
protractor protractor.conf.js — in e2e folfer run this command, it open browser


1.If you want to work with radio buttons and its selection that generates dynamically…you can achieve by following code..

var items = element.all(by.css(‘div.inputClass md-radio-group’));
console.log(“item count “, count);

for(var i=0;i<count;i++){
var controlid = ‘question’ + i;
console.log(“controlid=== “, controlid);

2. if you want to check where the control can do same like in js files by using console.log(); here this will show in your command prompt.

3. you can use browser.sleep(10000) like that to check where the control is..

4. Similarly if you want to check the url where the control presents..try this..

}) ;