Why Protractor

Embarking on a new project where the requirement is to automate a website built on AngularJS, I started my research and Google googles PROTRACTOR on top.
Protractor 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. "
I proceeded with the installation and wasn't long before I could run a test script. Hurrayy!! It ran...
However, the question is why Protractor specifically when you have abundance of material and helpers for selenium for heaps of supporting languages and also, you could use JavascriptExecutor / execute_script to locate and perform actions ?
Uptil this point,though I am a huge fan of SeleniumWebdriver, I have come down to listing some points in favour of Protractor:
1) Foundation of a website: AngularJS is a JavaScript-based open-source front-end web application framework mainly maintained by Google . Protractor was made by people who created AngularJs and it understands and waits for the AngularJs to be bootstrapped.These applications have a lot running in background without any visible behavior change in browser and make life hell for Selenium to understand and synchronize.Thus scripts made in selenium end up having clumsy and complicated waits & sleeps.
browser.waitForAngular() in protractor instructs webdriver to wait until Angular has finished rendering and has no outstanding $http or $timeout calls before continuing.
Note:Protractor automatically applies this command before every WebDriver action.
2) Locators: Protractor provides angular specific locator strategy.They provide options to select elements by angular models, bindings, ng-options – and finding elements inside ng-repeat.
HTML Element on the Application page:
Element location in Protractor :
Element location in Selenium: There is no unique way to identify this element in Selenium and have to depend on identifying any unique neighboring element and provide a relative path. Basically a lot of looping.
Some extra element locator techniques provided by Protractor :
3) Lines of code in a protractor script is potentially less.
I am expecting selenium-webdriver future updates to include locator strategies and bridge the gap between AngularJS app and itself. As I mentioned, I am a huge fan of selenium-webdriver this is something I am really looking forward to, till then
Happy PROTRACTORing !
FAQ: https://github.com/angular/protractor/blob/master/docs/faq.md

Comments

Popular Posts