0

I'm using protractor 4.0.14 on an angularjs application.

We are doing an async call that takes 30 seconds with a loading bar. So I'm waiting for an element that appears after that time. The loading bar always goes to 100%, then intermittently get stuck at 100% because of the browser.wait, but most of the time it works and display the element I'm looking for.

When it doesn't, it's just stuck on 100%, gets a timeout, then continue the tests. Only happens with protractor, manually on a browser, it never gets stuck.

it('Should wait for the end of the api call', function () {
    browser.wait(function () {
        return $('#loaded i.check').isPresent();
    }, 60000);
    expect($('#score button').isPresent()).toBe(true);
}, 61000);

I tried to use the ignoreSynchronization to true, I tried using implicitlyWait, wait for an Expected Condition "EC", used browser.driver.wait instead of browser.wait, sleep, but nothing changes the problem. It sometimes get stuck on the loading bar, preventing the application to continue.

Any suggestion?

Edit: Not a protractor issue. I managed to recreate the error in a regular Chromium browser manually.

bwarff
  • 365
  • 3
  • 16

3 Answers3

0

You can do it simpler. You can wait for '100%' text in element. Here you have a code:

return browser.wait(ExpectedConditions.textToBePresentInElement(element, '100%'), 60000);

The only thing you have to do is to replace element with an object where text should be visible.

Btw. your expect assertion does not work because of lack of chai-as-promise library. Similar issue

Kacper
  • 1,201
  • 1
  • 9
  • 21
  • Actually, expect is supposed to resolve the promise of the located element. It works everywhere else with only protractor using jasmine without any other library. Tried the solution with the 100%, didn't do the trick either. Probably because it waits the 100% but the 100% can appear really quickly and fade while the app continues. Then it timeouts anyway. – bwarff Jun 20 '17 at 13:45
0

Try below code.

var EC=protractor.ExpectedConditions;
var ele=$('#loaded i.check')

it('Should wait for the end of the api call', function () {
 browser.wait(EC.visibilityOf(ele),60000,"NOT VISIBLE");
 expect($('#score button').isPresent()).toBe(true);
});
Optimworks
  • 2,537
  • 17
  • 20
  • Tried it, had an error with the var ele outside the it, like if the browser element was not defined. And inside the it, it just acted the same, blocking on 100% and sometimes working. – bwarff Jun 20 '17 at 12:54
0

It wasn't a docker problem since I managed to recreate the bug without protractor on chromium.

the cause was a network error : err-network-changed

bwarff
  • 365
  • 3
  • 16