Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can angularjs apps be automated with selenium? if yes, why should we use protractor?

I know that we can automate AngularJs apps with Selenium. But we have a separate E2E testing framework that is Protractor for AngularJs apps automation.

Can anyone help me understand why we should use Protractor? Why not Selenium?

like image 792
Suresh Salloju Avatar asked Dec 09 '14 14:12

Suresh Salloju


People also ask

Can AngularJS application be automated using Selenium?

There is a library called ngWebDriver that is designed to automate AngularJS and Angular Web Applications using Selenium with Java. This library is developed by having all the JavaScript created for a Protractor Project.

Can Selenium handle AngularJS applications?

Selenium API has implementations in several major programming languages - allowing you to write your tests in Java, C#, python, ruby, JavaScript and more. If you already have a selenium-based e2e testing framework in place - you can use it also for AngularJS web-apps.

Why we should use Protractor instead of Selenium?

Both Selenium and protractor are automated test tools for web applications. Both are used to automate Angular Applications. As Protractor is specially designed for angular applications, so if you are testing angular applications, it is better to opt for a protractor.

Why Protractor is used for Angular applications?

Protractor supports Angular-specific locator strategies, which allows you to test Angular-specific elements without any setup effort on your part.


1 Answers

Not sure I understand your question. Am I right to assume you'd rather use Selenium - but want to understand what you're missing?

Well - Selenium provides means to automate web browsers - and thus used for automated e2e tests. Selenium API has implementations in several major programming languages - allowing you to write your tests in Java, C#, python, ruby, JavaScript and more.

If you already have a selenium-based e2e testing framework in place - you can use it also for AngularJS web-apps. You can also write the necessary JavaScript scripts that, once ran using the webdriver - will let you do all that Protractor does - but you'll have to do it yourself (just borrow from Protractor source code).

Why is it doable? Because Protractor basically took the JavaScript implementation of Selenium Webdriver and wrapped it in a way that makes your life a bit easier when testing Angular JS web apps.

You can see specific explanations in this old post of mine: http://testautomation.applitools.com/post/94994807787/protractor-vs-selenium-which-is-easier

I'd say that if you: 1. want to write your test code in JavaScript 2. are focused on mainly Angular JS apps

You might want to consider using Protractor. Again - no magic there. Everything they did is there in their source code - so you can just take your picks if you'd rather stick with selenium.

like image 124
Doron Zavelevsky Avatar answered Oct 05 '22 11:10

Doron Zavelevsky