Angular Protractor and Automation Testing
Testing is an integral part of every developer’s process. It is a requirement to make sure that your piece of work does what it claims to do without causing much trouble. Testing is not a process that can be cut from the same cloth as its overall outline. There are various testing means from Unit testing, Black box Testing, Whitebox testing etc., E2E testing is one such process that deals with automation, Angular protractor is one automation testing tool.
With the aim to reduce time consumption and complications, automated testing was introduced; Automated testing uses a tool or a piece of code to test. You don’t require human interaction to get the job done.
Before you ask if this might suit you, let me give you a little insight. E2E testing is best if you want to test the functional status. E2E lets you test like a GUI user, with buttons and pages.
The approach we are going to deal with today is using Angular Protractor built with Selenium. So, what does Protractor do? ; According to the site, “It is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application, running in a real browser, interacting with it as a user would.”
So, what was my problem? While implementing the e2e testing, it didn’t get us to our desired results; That’s when we started looking out for solutions and we came to realize the issue. The Protractor hasn’t been set for global access. As much as this seems simple this can go unnoticed. To make sure you don’t come across this, let me walk you through this process.
Setting up Protractor
How to install protractor.
To install Protractor, run the command line,
Then you install web driver manager for selenium.
Follow by initiating with the command
Build a test
Now that you have learnt how to setup, lets test how it works.
Create two files, a spec and a config file. The config file sets location of spec files. It also contains the web drivers; default set to Chrome. The Selenium or the server you use, include its address to communicate.
Now if you cannot see the wanted changes. It maybe because your web driver is not up-to-date. Follow through with the following details.
In command prompt type in the following command to install webdriver-manager package globally.
After download, just start up the server and you are good to go.
Now you can send a test request by Protractor to the Selenium Server and can view the status in the local browser. At last, we got the result in default Chrome browser.