Protractor Vs Selenium

Protractor and Selenium both are used to automate front end of web based applications. Generally most of the people are well aware of Selenium ( Java and Python bindings) and afraid of choosing any other tool on top of Selenium. I will compare Selenium and Protractor in this post, which will help you to decide which tool is best suited for your requirement.

Official website of Selenium says that:- Selenium automates browser. It does not specify any specific technology based web applications. Selenium can be used to automate any technology based application which needs a browser.

Official website of Protractor says that:- Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor is designed specially for automating Angular applications. Although Protractor can be used for any non-angular application as well but the beauty of Protractor for Angular application will be missed.

Let’s compare Protractor and Selenium ( Selenium WebDriver) on different Comparison Basises:-

Comparison BasisSelenium Protractor
Supported Front End Technology Based Web ApplicationIt is supposed to support any front end technology based applications as it does not specify support for any specific technology.It is specially designed for Angular and AngularJS applications. You can use for Non-angular applications as well.
Supported LanguagesC#, Haskell, Java, JavaScript, Objective-C, Perl. PHP, Python, R , RubyJavaScript and TypeScript. NodeJS provides runtime environment to run JavaScript programs
Supported BrowsersChrome, Firefox, Internet Explorer ( IE) , Microsoft Edge , Opera, Safari, Phantom (No longer officially supported.), HtmlUnitDriverChrome, Firefox, Internet Explorer ( IE) , Microsoft Edge , Safari, Phantom(No longer officially supported.)
Synchronization or WaitingNo automatic synchronization between your tests and application. You need to explicitly synchronize your tests with application using different kinds of supported waits in Selenium.It supports Automatic wait for Angular applications. It waits for webpage to finish pending works before executing next step in your tests. Automatic wait is not applicable for Non-angular applications. You can also wait explicitly in Protractor as well
Supported Locators StrategiesIt supports common locator strategies for all types of web applications:- Id, name, className, linkText, partialLinkText, tagName, xpath and css .It supports all types of locator strategies supported by Selenium plus extra angular specific locator strategies such as model, repeater, binding, buttonText, option etc. You can create custom locator as well.
Supported Test FrameworksIt supports different Test Frameworks depending of language binding. It does not come with default framework.
C#- NUnit,
Java- JUnit, TestNG
Python- PyUnit, PyTest
JavaScript- WebDriverJS, WebDriverIO
It supports Jasmine and Mocha. Jasmine comes as a default test framework with Protractor.
Support for BDDYes. (Cucumber, Serenity, JBehave etc).Yes. Jasmine. Mocha, Cucumber and Serenity/JS
ReportingNo default reporting. Need to integrate with third party tools:- TestNG, Extent Report, Allure Report etc. No default reporting. Need to integrate with third party tools. We will find so many reporting options compare to Selenium. Some are protractor-beautiful-reporter, protractor-html-reporter etc
Managing browser driversIt does not manage browser drivers automatically. You need to explicitly sync browser version and driver. You can use third party tool like WebdriverManager to automatically sync browser version and driver. It supports automatic sync between browser version and driver for Chrome and Firefox. You need to use webdriver-manager CLI to do so.It will download Selenium version and browser drivers as per need.
Parallel TestingNo default support. Need to integrate with third party tools like TestNG for Java binding of Selenium.Default support for parallel testing. You can parallely run same or specific specs in different or same browsers. It is very easy to setup parallel execution in Protractor compare to Selenium.
CostOpen sourceOpen source
Nature of Execution Synchronous (Depends on Language binding. JavaScript binding is not synchronous)Asynchronous as Protractor is a wrapper on WebDriverJS.
Needed Technical SkillsAverageModerate
SupportNo official support but It has a large open community. No official support and It has not a large open community like Selenium.
Ease to automate Angular ApplicationsNot easy. You will face a lot of sync issues. It is difficult to find out the actual wait conditions.Easy as it is designed for angular applications. Automatic wait for loading of angular component and angular specific locator strategies make your life easier
Test Execution SpeedSlowerFaster
Ease of ScriptingLess. Need to write more lines of code.More compared to selenium. Many setup can be handled through configuration files instead of codes.
Support for Mobile ApplicationNo direct support by Selenium, Need to use Appium for Mobile automation. Direct support by Protractor for Mobile application automation.
CI/CD integrationYesYes
Docker SupportYesYes
DebuggingEasyDifficult
Test Script StabilityChances of flaky tests moreMore stable scripts compare to Selenium

Conclusion:-

So Selenium and Protractor both can be used to automate Angular Applications. If your application is an Angular application, you should try to use Protractor as It is designed specially for them. Although you are expert in Selenium-Java but you can not bound yourself within a technology. There are many tools coming in market which are better than Selenium.

Protractor is also an open source tool like Selenium so costing will not be an issue. You may be need to start with scratch with Protractor but you will enjoying learning and working with Protractor.

#ThanksForReading

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.
%d bloggers like this: