angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Timeout while waiting to synchronize #460

Closed FrankyBoy closed 10 years ago

FrankyBoy commented 10 years ago

Hi! I just picked up mobile testing here and having a go at our site with protractor (as we dearly miss decent automation on mobile), but couldn't get it to even load up properly (protractor, that is). The whole testcase is:

describe('ms2 homepage', function() {
  it('should not redirect', function() {
    browser.get('https://sports.m.bwin.es/en/sports');
    expect(browser.getCurrentUrl()).toContain('sports.m.bwin.es/en/sports');
    // yes, thats pretty redundant, but its good enough for triggering the issue
  });
});

which results in a timeout with this output:

D:\svn\MS2\FuncTest>protractor conf.js
Using the selenium server at http://localhost:4444/wd/hub
F

Failures:

  1) ms2 homepage should not redirect
   Message:
     Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds
   Stacktrace:
     Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds
    at Error (<anonymous>)
    at [...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1318:15
    at [...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1467:7
    at [...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1178:15
    at webdriver.promise.ControlFlow.runInNewFrame_ ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\
webdriver\promise.js:1445:20)
    at notify ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:328:12)
    at notifyAll ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:297:7)
    at handleRejection ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:419:7)
    at reject [as errback] ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:429:
7)
    at reject ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1631:5)
==== async task ====
WebDriver.executeScript()
    at webdriver.WebDriver.schedule ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdri
ver.js:267:15)
    at webdriver.WebDriver.executeAsyncScript ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdri
ver\webdriver.js:507:15)
    at Protractor.waitForAngular ([...]\npm\node_modules\protractor\lib\protractor.js:407:22)
    at to.(anonymous function) [as getCurrentUrl] ([...]\npm\node_modules\protractor\lib\protractor.js:41:7)
    at null.<anonymous> (D:\svn\MS2\FuncTest\example_spec.js:5:20)
    at [...]\npm\node_modules\protractor\jasminewd\index.js:54:12
    at webdriver.promise.ControlFlow.runInNewFrame_ ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\
webdriver\promise.js:1445:20)
    at webdriver.promise.ControlFlow.runEventLoop_ ([...]\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\w
ebdriver\promise.js:1310:8)
    at wrapper [as _onTimeout] (timers.js:252:14)
==== async task ====
    at null.<anonymous> ([...]\npm\node_modules\protractor\jasminewd\index.js:53:12)
    at null.<anonymous> ([...]\npm\node_modules\protractor\node_modules\minijasminenode\lib\async-callback.js:45:37)
    at jasmine.Block.execute ([...]\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:1168:17)
    at jasmine.Queue.next_ ([...]\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2200:31)
    at null._onTimeout ([...]\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2190:18)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Finished in 12.181 seconds
1 test, 1 assertion, 1 failure

I also already tried increasing the timeout to bigger values but with no success.

juliemr commented 10 years ago

Please look at the first question in the FAQ: https://github.com/angular/protractor/blob/master/docs/faq.md

If that does not answer your question, please open a question on StackOverflow, or if you really believe you've found a bug with Protractor post a new issue here.

softvar commented 10 years ago
describe('Testing Protractor', function() {
  var draftList;
  var ptor;

  beforeEach(function() {
    ptor = protractor.getInstance();
    ptor.ignoreSynchronization = true;
  });

  it('should count the number of drafts', function() {
    ptor.get('#/');
    draftList = element.all(by.repeater('newsletter in drafts'));
    expect(draftList.count()).toEqual(2);
  });
});
enricorotundo commented 9 years ago

i've the same issue and @softvar solution works but i wonder if is safe set ignoreSynchronization = true???

thilinadinith commented 9 years ago

@juliemr - protractor in angular is not working with changing pages with synchronization

Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds

option is making the ignore.Synchronization = true ; But then again its getting problem that angular is not define as its not synchronized

@juliemr - DO NOT TELL LOOK YOUR DOCUMENTATION AS THERE IS NOTHING on it and people get really helpless due to your poor documentation !!

FrankyBoy commented 9 years ago

ok, then I will ... RTFM, it really helps at times.

juliemr commented 9 years ago

I know that the timeout documentation isn't as complete as it could be, and we'd love suggestions for how to improve it. It's a tricky area, because the problem is often in the application being run - as the FAQ says, if there are $http or $timeout requests pending in your application, synchronization will fail. Sometimes, pages are using components that have continuous $timeout requests that they don't even know about.

The good news is that I'm working on a different way of handling synchronization, which should make it easier to turn off and to see exactly what is happening. The way it will work is via a proxy before sending commands to webdriver. Stay tuned...

@FrankyBoy I hope the FAQ was able to help you!

thilinadinith commented 9 years ago

@juliemr There is no #http or #timeout requests pending !! My application is SAP application and it has html login page with angular module and index page after login with an angular module ..... still the synchronization fails most of saying a temporary fix browser.ignoreSyncronization = true which will cause to many errors when we have more test cases in single test module

expecting a correct answer assap PLEASE DONT EVER SAY TO LOOK DOCUMENTATION i read it already and it wont help for this problem

Thankz

FrankyBoy commented 9 years ago

Jop, we had a bunch of $timeouts in a loop (slideshow) which for obvious reasons failed to ever be considered "stable". Right now we (actually another department) have only one "problem" with the sync which is that they have auto-hiding notification messages (which use $timeout) which then obviously block until they disappear ... and their devs are like "We'll never use $interval with 1 repetition for that" so tough luck ;)

@thilinadinith srsly, learn some manners. also maybe provide some code to reproduce the issue, because right now you are just flaming around. If there really is an issue in protractor I can say from the past that it usually got treated with the appropriate seriousness.

MaestroJurko commented 9 years ago

protractor.getInstance() is unefined

fuel-shea commented 8 years ago

Completely agree with @FrankyBoy that @thilinadinith needs to go easy. A better way to deal with dissatisfaction might be to fix the problem yourself. You are using free, open-source software, after all.

Thanks for your hard work, @juliemr .