Saturday, July 30, 2016

Protractor Basic Functions


Protractor Few Generic Functions


This is my second blog, where I will show few generic functions for protractor with usage.


This is the generic function for selecting value from drop down. It requires two parameters, one for the modelName and second for the index value which you want to select.


 this.selectDropdownValue = function(dropdownmodelname,index){  
    element(by.model(dropdownmodelname)).$('[value="' + index + '"]').click();  
 };  

Sunday, June 7, 2015

Protractor Installation

       This is the my first blog, where I demonstrate how to install protractor on windows machine. Now what is protractor, well protractor is a nodejs program that's use to write end-to-end tests, tests which are written in javascript to stimulate user stories in web browser. Protractor effectively is built upon webdriver, so lot of the stuff we do with selenium is also possible with protractor.

      So first we will setup our environment to run protractor tests, for this we have to first download a browser which stimulate user stories and for this we download google chrome. To download google chrome go to here and click on download chrome and install it. The next thing we have do is to download and install nodeJs, so for this go to here and click on install button. After clicking the install button follow the steps to install it completely. By the way, NodeJs is a event-driven, lightweight and efficient, pefect for data-intensive real-time applications that run across distributed devices that we can use to build applications. After this, the next thing we have to do is to ensure that the nodeJs is correctly installed on our machine. For this we will run a set of commands to make sure that it is done. To check this we have to use console window to make sure that everything is fine. So just open up the cmd window. And once its open, you first type in "npm --version" and hit enter - and we get something like this..



And it should print out the version number, and if it does, it means that you actually installed the npm correctly and the parts have been setup. So the next thing we going to do is installed protractor. To do that, type in "npm install -g protractor" and hit enter, here -g refers to install protractor globally which means it allows us to access it anywhere. This could take few minutes but after you get something like this..


So now we are going to do is to make sure that we actually installed protractor. For this, we need to check the version of protractor which is running and for this we type in "protractor --version" and hit enter.


By this, we are insured that protractor is installed correctly in our system. You can also list of nodes which are installed under package manager, for this we type in "npm -g list" and hit enter and we get something like this..



This will give you a list of all nodes you have installed. Now to run protractor, we actually need a selenium server as well, to run selenium server you have installed java jdk in your machine. So the next thing we are going to do is install java jdk in our machine and for this go to here and click on download button and install it. After completing the installation, the next thing we going to do is to open console window again and type in "java -version" and hit enter, just to confirm that java is installed correctly or not. We will get something like this..


After installing java, now we need to run selenium server in order to run our protractor tests. But before we run selenium server through web driver manager, we first going to run webdriver manager update for updating our web driver manager we currently have, and for this we type in "web driver-manager update" and hit enter. We will get something like this..


And as we can see from the above screenshot, its updating chrome driver. After completing this, we will start our selenium server and for this we type in "webdriver-manager start" and hit enter and will get something like this,