3

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.

BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287

1 Answers1

6

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;
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • do you know why is this happening? have same issue with only one basic test – genuinefafa Dec 15 '17 at 14:46
  • @genuinefafa could be multiple reasons for that - oftentimes it's the use of $timeout in the angular application itself. – alecxe Dec 15 '17 at 14:51
  • 1
    For me it is the `TimerObservable` creating an interval. If i comment this section, the tests run as usually. This is also happening with `setTimeout()`. – Guntram Mar 16 '18 at 09:19