Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use Protractor on non angularjs website?

I have found Protractor framework which is made for AngularJS web applications.

How can I use Protractor on a website which is not using AngularJS?

I wrote my first test and Protractor triggers this message:

Error: Angular could not be found on the page https://www.stratexapp.com/ : retries looking for angular exceeded 
like image 378
Abdelkrim Avatar asked Jan 04 '14 22:01

Abdelkrim


People also ask

Can Protractor be used for non Angular?

Protractor works well on non-AngularJS pages as well. The first step is to set browser. ignoreSynchronization = true; inside the beforeEach() block in the spec file, to signal Protractor not to wait for Angular components to load.

Does Protractor support Angular?

But as AngularJS evolved, Protractor also quickly became popular due to unique features like being open-source, being easy to set up, and out of the box support for all major browsers. Until its deprecation, Protractor supported automation of both Angular and non-Angular-based applications.

How do you invoke a Protractor browser?

Protractor provides a method called maximize(), which helps the user to maximize the browser window. import { browser} from 'protractor' describe('Protractor Typescript Demo', function() { it('title verifications', function() { browser. get('https://angularjs.org/'); browser. manage().

Why Protractor is used for Angular applications?

Protractor is made specifically for Angular apps. It supports Angular-specific locator strategies, which allows you to test Angular-specific elements without any setup effort on your part.


2 Answers

Another approach is to set browser.ignoreSynchronization = true before browser.get(...). Protractor wouldn't wait for Angular loaded and you could use usual element(...) syntax.

browser.ignoreSynchronization = true; browser.get('http://localhost:8000/login.html');  element(by.id('username')).sendKeys('Jane'); element(by.id('password')).sendKeys('1234'); element(by.id('clickme')).click(); 
like image 81
Andrei Beziazychnyi Avatar answered Oct 13 '22 06:10

Andrei Beziazychnyi


If your test needs to interact with a non-angular page, access the webdriver instance directly with browser.driver.

Example from Protractor docs

browser.driver.get('http://localhost:8000/login.html');  browser.driver.findElement(by.id('username')).sendKeys('Jane'); browser.driver.findElement(by.id('password')).sendKeys('1234'); browser.driver.findElement(by.id('clickme')).click(); 
like image 27
Eitan Peer Avatar answered Oct 13 '22 04:10

Eitan Peer