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

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

问题描述

我正在尝试对未使用角度插件的引导模式进行 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/protractor/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)✗

是否有解决方法或者无法使用量角器测试 vanilla bootstrap 模态?

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.

推荐答案

你可能会有更多的运气暂时关闭同步:

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;

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

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