Protractor test a bootstrap modal - not angular page - timeout

自古美人都是妖i 提交于 2019-12-30 10:39:04

问题


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:

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?

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(); 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.


回答1:


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;


来源:https://stackoverflow.com/questions/40817733/protractor-test-a-bootstrap-modal-not-angular-page-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!