Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test login with protractor on a non angular page

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?

like image 869
Frederic Le Feurmou Avatar asked Oct 23 '14 20:10

Frederic Le Feurmou


2 Answers

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

like image 129
Sakshi Singla Avatar answered Nov 16 '22 01:11

Sakshi Singla


This is documented in the protractor website:

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

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

like image 20
Andres D Avatar answered Nov 16 '22 01:11

Andres D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!