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:-
|Supported Front End Technology Based Web Application||It 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 Browsers||Chrome, Firefox, Internet Explorer ( IE) , Microsoft Edge , Opera, Safari, Phantom (No longer officially supported.), HtmlUnitDriver||Chrome, Firefox, Internet Explorer ( IE) , Microsoft Edge , Safari, Phantom(No longer officially supported.)|
|Synchronization or Waiting||No 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 Strategies||It 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 Frameworks||It supports different Test Frameworks depending of language binding. It does not come with default framework.|
Java- JUnit, TestNG
Python- PyUnit, PyTest
|It supports Jasmine and Mocha. Jasmine comes as a default test framework with Protractor.|
|Support for BDD||Yes. (Cucumber, Serenity, JBehave etc).||Yes. Jasmine. Mocha, Cucumber and Serenity/JS|
|Reporting||No 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 drivers||It 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 Testing||No 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.|
|Cost||Open source||Open source|
|Needed Technical Skills||Average||Moderate|
|Support||No 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 Applications||Not 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 Speed||Slower||Faster|
|Ease of Scripting||Less. 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 Application||No direct support by Selenium, Need to use Appium for Mobile automation.||Direct support by Protractor for Mobile application automation.|
|Test Script Stability||Chances of flaky tests more||More stable scripts compare to Selenium|
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.
4 thoughts on “Protractor Vs Selenium”
will protractor support Reactive Js application
Nice and simple explanation.
can we use selenium 3+ to automate AngularJS applications ?
You can use Selenium as well.