简体   繁体   English

量角器测试引导模态 - 而非角度页面 - 超时

[英]Protractor test a bootstrap modal - not angular page - timeout

I'm trying to UI test a bootstrap modal which has not used an angular plugin, it is a vanilla bootstrap modal. 我正在尝试UI测试一个没有使用过角度插件的bootstrap模态,它是一个vanilla bootstrap模式。 I get this error: 我收到此错误:

Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. 失败:超时等待异步Angular任务在11秒后完成。 This may be because the current page is not an Angular application. 这可能是因为当前页面不是Angular应用程序。 Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular While waiting for element with locator - Locator: By(css selector, h2.modal-title)✗ 有关更多详细信息,请参阅常见问题解答: https//github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular在等待带定位符的元素时 - 定位器:By(css选择器,h2 .modal标题)✗

Is there a workaround for this or is it not possible to test a vanilla bootstrap modal with protractor? 有没有针对此的解决方法或是不可能用量角器测试香草自举模式?

Here is my full test: 这是我的全面测试:

import { browser, element, by, By, $, $$, ExpectedConditions } from 'protractor';
import { E2EUtilities } from './utilities.spec'

    describe('Result Details', function () {
       it(`Shows result details modal when clicking on a result`, function () {
          E2EUtilities.navigateToResultsPage();
          element(by.id('result0')).isPresent().then(function (result) {
             if (result) {
                element(by.id('result0')).click();
                browser.sleep(3000);
                expect(element(by.css('h2.modal-title')).isPresent()).toBe(true);
             } else {
                expect(element(by.css('h2.modal-title')).isPresent()).toBe(false);
             }
          });
       });
    });

Please note I have left E2EUtilities.navigateToResultsPage(); 请注意我已离开E2EUtilities.navigateToResultsPage(); concealed because I know the problem is not with that because The code gets through all that and goes further as can be seen by the eye. 隐藏,因为我知道问题不是那个,因为代码通过所有这些,并进一步,从眼睛可以看出。

You might have more luck turning the synchronization off temporarily : 您可能有更多运气暂时关闭同步

element(by.id('result0')).isPresent().then(function (result) {
  if (result) {
    browser.ignoreSynchronization = true;

    element(by.id('result0')).click();
    browser.sleep(3000);  // TODO: use ExpectedConditions?
    expect(element(by.css('h2.modal-title')).isPresent()).toBe(true);
  } else {
    expect(element(by.css('h2.modal-title')).isPresent()).toBe(false);
  }
});

browser.ignoreSynchronization = false;

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

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