1
votes

I have trouble with Protractor ignoreSynchronization.

I was not able to log in without using browser.ignoreSynchronization = true. After login ignoreSynchronization was not needed any more.

Here is the login code:

browser.driver.get('xxx');

browser.ignoreSynchronization = true;

$('#input-idCode').sendKeys(idCode);
$('#input-phoneno').sendKeys(mobileNum);
$('.mobile-id').click();

browser.wait(EC.presenceOf(nextButton), 15000);
browser.ignoreSynchronization = false;

In the next case, I am also testing Angular website, but the same solution did not work any more. After logging in I am redirected to main page and get error message: Failed: Timed out waiting for Protractor to synchronize with the page after 60 seconds. although the element I want to interact with is visible.

What could be the problem? I don't want to run tests with ignoreSynchronization = true.

2
If your error is "Timed out waiting for Protractor to synchronize...", that is not related to elements. Ask your devs if the app continuously polls $http or $timeout, typically used in a keepAlive service. See this document for reference. - Gunderson

2 Answers

0
votes

In your code, the get, sendKeys and click are executed asynchronously but browser.ignoreSynchronization is assigned synchronously. So when the control flow executes driver.get, the property ignoreSynchronization is already set to false.

To overcome this issue, push the assignment in the control flow:

browser.driver.get('xxx');

browser.controlFlow().execute(function() {
  browser.ignoreSynchronization = true;
});

$('#input-idCode').sendKeys(idCode);
$('#input-phoneno').sendKeys(mobileNum);
$('.mobile-id').click();

browser.wait(EC.presenceOf(nextButton), 15000);

browser.controlFlow().execute(function() {
  browser.ignoreSynchronization = false;
});
0
votes

Timed out waiting for Protractor to synchronize with the page after 50001ms

The problem I had: Your page is polling $timeout or $http repeatedly. Protractor won't do anything until Angular has reached a "resting" state (all elements and data bindings are loaded and all requests have returned).

Using $interval instead of $timeout or $http should fix the problem