简体   繁体   中英

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. 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.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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