简体   繁体   English

E2E如何在没有角度的情况下在其他网站上使用量角器测试?

[英]How E2E test with protractor at other website without angular?

I am building test cases, one of them is testing with protractor at other website and I only get error messages 我正在构建测试用例,其中一个是在其他网站上使用量角器进行测试,我只收到错误消息

Angular CLI: 7.3.8 Node: 11.13.0 OS: win32 x64 Angular: 7.2.14 Angular CLI:7.3.8节点:11.13.0 OS:win32 x64 Angular:7.2.14

beforeEach(function() {
  browser.get('http://xxx.xx/');
});

it('should have a title', function() {
  expect(browser.getTitle()).toEqual('XXX');
});

I expect that protractor regonise title of website and I get message "Failed: javascript error: angular is not defined" 我期望量角器重新命名网站的标题,我收到消息“失败:javascript错误:角度未定义”

The difference between Protractor and WebdriverJS is that before performing each command Protractor waits for Angular specific $http and $timeout tasks to complete. Protractor和WebdriverJS之间的区别在于,在执行每个命令之前,Protractor会等待Angular特定的$ http和$ timeout任务完成。

However, if you use Protractor in non-angular app you will notice that it simply doesn't do anything. 但是,如果您在非角度应用中使用量角器,您会发现它根本不做任何事情。 As per my understanding, protractor keeps looking for these tasks without any luck 根据我的理解,量角器一直在寻找这些任务而没有任何运气

This feature can be manually disabled using browser.waitForAngularEnabled(false) . 可以使用browser.waitForAngularEnabled(false)手动禁用此功能。

Once you disable you can interact with non-angular page. 禁用后,您可以与非角度页面进行交互。 But make sure add functions that would wait for the page to load. 但请确保添加等待页面加载的函数。

Thus you'll have something like 因此你会有类似的东西

it('should have a title', function() {
  browser.get(angularPage);

  // disable waiting for angular
  browser.waitForAngularEnabled(false);

  // open non angular page
  $redirectingLink.click();

  // do whatever you want here
  expect(browser.getTitle()).toEqual('XXX');

  // enable the feature back on
  browser.waitForAngularEnabled(true);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM