Before we can start using Protractor we have to do a few things to get Protractor Test Set Up. Feel free to jump ahead if you already have any of these pieces set up on your system.
This setup guide has 5 parts to install:
- Java Development Kit
- Install Drivers
Note this post contains affiliate links. It doesn’t cost you anything extra to use these links, but it helps to support this blog.
Java Development Kit Installation
First, let us check to see if you already have Java installed on your system. Open a console window and type “java -version”. If you see something similar to what we get, you should be good to go.
If you don’t have Java installed you will need to first download it from the Oracle website, here.
Open the installer and take all the defaults. When you are done, go back to your console window and type:
You should now see the output that we were looking for just a few moments ago.
NOTE: If you get this message “‘java’ is not recognized as an internal or external command, operable program or batch file.” then you are going to need to set JAVA in your environment variables. See this article to determine how to fix this for your Operating System.
Head over to nodejs.org and download the installer for your system. I recommend installing the “LTS” version since this will be the most stable build. Just take all the defaults when installing.
To check if Node was installed correctly, open a console window and enter the command:
If you get a version number, then you are all good.
When you installed Node you also got NPM. NPM is nodes package manager, which lets us easily install things to our system. We are going to use NPM to download and install the Protractor Framework all in one easy command.
Open that console window and type:
“npm install -g firstname.lastname@example.org”
This command will download and install protractor. You may notice the “@5.0.0” bit at the end. That part of the command tells NPM to get that specific version of Protractor. There are some compatibility issues with the newer version of Protractor and some of the plugins that I will be using, so I am going to keep us all on the same page by specifying the version.
The “-g” flag tells NPM to install Protractor globally.
Run the command to make sure Protractor was installed correctly:
You should see the version number printed to the console.
Once again we will use NPM to install another package. We need to install webdriver-manager globally. Run this command:
“npm install -g webdriver-manager”
Once the installation is finished make sure everything is working by running this command:
You should get a list of available command for webdriver-manager.
When I say “drivers” I don’t mean the things you install to get your hardware to work on your computer. I am talking about the drivers that will run Chrome and Internet Explorer for our tests.
Open that console again. Run these two commands:
“webdriver-manager update –ie”
You just installed the drivers for Chrome and Internet Explorer. Run this command to see the details:
You should see a list of the installed drivers and their versions.
Congrats! You are not ready to start writing some tests. Well, almost… We need to set up the config file first.
These posts are an introduction to Protractor for Automated Testing. To learn more with a full hands-on guide, grab our course on Udemy for only $9.99 when you use my link. Website Automation for Beginners with Protractor