量角器测试引导程序模态-不是角度页面-超时 [英] Protractor test a bootstrap modal - not angular page - timeout

查看:73
本文介绍了量角器测试引导程序模态-不是角度页面-超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试UI测试没有使用角度插件的引导程序模版,它是香草的引导程序模版.我收到此错误:

I'm trying to UI test a bootstrap modal which has not used an angular plugin, it is a vanilla bootstrap modal. I get this error:

失败:等待异步Angular任务完成时超时 11秒后.这可能是因为当前页面不是 角度应用.请参阅常见问题解答以了解更多详细信息: https://github.com/angular/量角器/blob/master/docs/timeouts.md#waiting-for-angular 在等待带有定位符的元素时-定位符:By(css选择器, h2.modal-title)✗

Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. 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)✗

是否有解决方法,或者无法使用量角器测试香草自举模态?

Is there a workaround for this or is it not possible to test a vanilla bootstrap modal with protractor?

这是我的完整测试:

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);
             }
          });
       });
    });

请注意,我已经隐藏了E2EUtilities.navigateToResultsPage();,因为我知道问题不在于此,因为代码可以遍历所有内容,而且可以通过肉眼看到的更进一步.

Please note I have left 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.

推荐答案

您可能还有更多运气暂时关闭同步:

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;

这篇关于量角器测试引导程序模态-不是角度页面-超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆