angular / protractor

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

Error: Error while waiting for Protractor to sync with the page: {} when trying to query elements in a popup window #334

Closed romankolpak closed 10 years ago

romankolpak commented 10 years ago

I'm trying to test Facebook login in my app, and since it's done in a popup, things are getting messy. This is pretty much the whole code of the test:

// the click is supposed to open the Facebook login dialog
element(by.xpath('//div[@id="login-form"]/a')).click();

var handlesPromise = ptor.getAllWindowHandles();

handlesPromise
  .then(function(handles) {
     return ptor.switchTo().window(handles[1]);
  }).then(function(handle) {
     // here's where I'm getting the `Error: Error while waiting for Protractor to sync with the page: {}`
    // It seems that scheduling any commands at this point will result in this error
    element(by.id('email')).sendKeys('wut'); 
  });

Is this a bug or correct behavior? Am I missing something?

juliemr commented 10 years ago

I'm guessing that the pop up page does not have Angular on it, is that correct? In this case, you'll need to use the base webdriver instance:

browser.driver.findElement(by.id('email')).sendKeys('wut')
romankolpak commented 10 years ago

Yeah, you're right. Thanks a lot! I guess this was more of a stackoverflow kinda question rather than a github issue :) Sorry about that

morgs32 commented 10 years ago

if this were on stack overflow upvote julie's answer

StoneCypher commented 9 years ago

It is: http://stackoverflow.com/questions/18382866/can-protractor-test-a-login-that-is-not-angular-based