Protractor for not Angular web apps

When you need to tests AngularJS apps, it is well known that Protractor is the tool of choice to ease the e2e automated tests development. If your app is not AngularJS, it is also well known you can still use Protractor…is it well known?

When choosing a tool, make sure you know how it works

Among others, the benefits of using Protractor to test AngularJS apps are how it uses the webdriver control flow and the angular locators such as by.model or by.binding

But what happens if the engineering team decides to change the app and use a new technology that is not Angular? Should we change the e2e test automation tool or framework? No.

If you get something like this, do not panic:

Failed: Angular could not be found on the page

Failed: Error while running testForAngular: asynchronous script timeout

You can keep using Protractor but some tweaks are needed.

By default, Protractor assumes that the app under test is an Angular app. That’s why Angular is always checked before each test. So the change you need to do is to tell Protractor that the app under test is not Angular. How can we do that?

Option 1: on each test case.

it('My not Angular app tests', () => {
browser.ignoreSynchronization = true;
// Test steps here
});

or

beforeEach(() => {
browser.ignoreSynchronization = true;
});

Option 2: set up the whole suite in the configuration file using the onPrepare hook:

onPrepare: () => {
browser.ignoreSynchronization = true;
}

Check a working example test over the-internet login at https://github.com/tavotester/examples-protractor/tree/not-angular

Enjoy Protractor! 💪