在非角度页面上使用量角器测试登录

时间:2021-11-01 04:51:28

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.

我正在尝试使用量角器进行e2e测试,但首先我需要在非角度页面上登录。我尝试直接使用webDriver,如此处所示,但它失败了。

My e2e test:

我的e2e测试:

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?

你知道解决方案吗?

3 个解决方案

#1


10  

You need to use

你需要使用

browser.driver.get 

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

而不是用于非角度页面的browser.get。此外,您需要设置

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

我为非角度页面添加了一个页面。您可以参考相同的内容:https://github.com/sakshisingla/Protractor-Non-Angular-Tests/wiki/Creating-test-scripts-using-Protractor-for-non-angular-application

#2


1  

This is documented in the protractor website:

这在量角器网站中有记录:

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

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

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

在如何处理我的登录页面?

#3


0  

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;

#1


10  

You need to use

你需要使用

browser.driver.get 

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

而不是用于非角度页面的browser.get。此外,您需要设置

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

我为非角度页面添加了一个页面。您可以参考相同的内容:https://github.com/sakshisingla/Protractor-Non-Angular-Tests/wiki/Creating-test-scripts-using-Protractor-for-non-angular-application

#2


1  

This is documented in the protractor website:

这在量角器网站中有记录:

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

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

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

在如何处理我的登录页面?

#3


0  

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;