Test login with protractor on a non angular page

All we need is an easy explanation of the problem, so here it is.

I am trying to use protractor for e2e testing but first I need to login on a non-angular page. I try to directly use the webDriver as indicated here but it fails.

My e2e test:

describe('angularjs homepage', function() {

  it('should prompt the login page', function() {
    browser.get('/');
    expect(browser.driver.find(By.id('user_password')));
  });

});

My logs:

Running "protractor:all" (protractor) task
Using the selenium server at http://localhost:4444/wd/hub
F

Failures:

  1) angularjs homepage should prompt the login page
   Message:
     TypeError: Object [object Object] has no method 'find'

Do you know a solution?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

You need to use

browser.driver.get 

instead of browser.get for Non-Angular pages. Also, you need to set

browser.driver.ignoreSynchronization = true in the beforeEach() function

I have added a page for non-angular pages. You can refer to the same:
https://github.com/sakshisingla/Protractor-Non-Angular-Tests/wiki/Creating-test-scripts-using-Protractor-for-non-angular-application

Method 2

This is documented in the protractor website:

http://angular.github.io/protractor/#/faq

under How do I deal with my log-in page?

Method 3

For a non angular page, first use this

browser.ignoreSynchronization = true;

The above line will tell protractor that it’s not an angular page, and you can perform any action on your non-angular page. Now when you are done, and want to move to an angular page use

browser.ignoreSynchronization = false;

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply