Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

browser.ignoreSynchronization=true is not recognized after browser.restart() #3677

Closed
mwsessom opened this issue Oct 28, 2016 · 7 comments
Closed
Assignees
Milestone

Comments

@mwsessom
Copy link

Setting browser.ignoreSynchronization = true; after browser.restart() is ignored.

describe('Test1', function() {
    it('Browser ignoreSynchronization test', function() {
        browser.driver.get("https://angularjs.org/");

        browser.restart();

        browser.ignoreSynchronization = true;
        browser.driver.get("https://github.com/");

        var EC = protractor.ExpectedConditions;

        //fails here
        browser.driver.wait(EC.visibilityOf($("#start-of-content")));
      })
});

Output: Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"

Protractor 4.0.10
Chromedriver 2.25
Chrome 54.0.2840.71

@heathkit heathkit self-assigned this Oct 28, 2016
@heathkit heathkit added this to the Upcoming milestone Oct 28, 2016
@heathkit
Copy link
Contributor

Thanks for the test case! It looks like this was caused by #3651, which was trying to fix #3648.

The heart of the issue is that when browser.restart() creates a new browser instance and copies it's properties over to the existing global browser instance, the webdriver mixins still have a waitForAngular call that's bound to the old instance. Luckily, it looks like the only thing this would break is ignoreSynchronization after a browser.restart() call.

@mblasiusnyc
Copy link

mblasiusnyc commented Nov 1, 2016

@mgiambalvo: I believe this issue may affect browser.ignoreSynchronization in more cases than just when browser.restart is called. I am still seeing Protractor.waitForAngular() getting called after I have set browser.ignoreSynchronization to true.

EDIT:In my situation, I think _browser.restart() was being called by protractor-cucumber-framework. Not sure about this though...

@justin-calleja
Copy link

After updating Protractor from 4.0.9 to 4.0.10 I'm getting:

Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"

@azachar
Copy link

azachar commented Dec 17, 2016

Hi There,
I am getting a very similar issue still on the version 4.0.13, it happens sometimes...

the test opens the page and waits to have a certain part in the url using the function bellow, the tests are using browser.restart() in afterEach. Since I am using a random order of running, it happens only sometimes.

  this.waitForUrl = function(url, timeout) {
    timeout = timeout || DEFAULT_WAIT_FOR_TIMEOUT;
    return this.browser.wait(EC.urlContains(url), timeout, 'waiting url to contains ' + url);
  };

I am getting this error:

Failed: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
    at WebDriverError (/home/ubuntu/xxx/node_modules/selenium-webdriver/lib/error.js:27:5)
    at NoSuchSessionError (/home/ubuntu/xxx/node_modules/selenium-webdriver/lib/error.js:170:5)
    at checkHasNotQuit (/home/ubuntu/xxx/node_modules/selenium-webdriver/lib/webdriver.js:395:15)
    at Driver.schedule (/home/ubuntu/xxx/node_modules/selenium-webdriver/lib/webdriver.js:356:5)x
    at Driver.getCurrentUrl (/home/ubuntu/xxx/node_modules/selenium-webdriver/lib/webdriver.js:804:17)
    at /home/ubuntu/xxx/node_modules/protractor/built/expectedConditions.js:306:41

The screenshot from this failure clearly shows that the page is fully loaded and has its content so I guess this might be a bug. I guess that is related to this issue too.

Anyway, thank you for your help.

Best regards,
Andrej

@azachar
Copy link

azachar commented Dec 17, 2016

Here is the failing test case:

describe('This driver instance does not have a valid session ID', function() {
  var EC = protractor.ExpectedConditions;

  function waitForUrl(url) {
    browser.wait(EC.urlContains(url), 5000).then(function() {
      console.log(url + ' found');
    })
  }

  it('Browser wait for url fails', function() {
    browser.get("https://angularjs.org/");
    waitForUrl('angular');

    browser.restart();

    browser.get("https://angularjs.org/");
    //fails here // This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
    waitForUrl('angular');
  });

  it('Browser ignoreSynchronization fails', function() {
    browser.get("https://angularjs.org/");
    browser.restart();
    browser.get("https://angularjs.org/");

    browser.ignoreSynchronization = true;
    browser.get("https://github.com/");
    waitForUrl('github'); //fails here This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.

    browser.ignoreSynchronization = false;

    browser.restart();

    browser.get("https://angularjs.org/");
    waitForUrl('angular');
  });

});

here is protractor.conf

{ 
  rootElement: 'html', //it fails also with [ng-app]
  allScriptsTimeout: 110000,
  baseUrl: 'http://localhost:9000',
  chromeOnly: true,
  directConnect: true,
  exclude: [],
  capabilities: { browserName: 'chrome' },
  framework: 'jasmine',
  jasmineNodeOpts: { defaultTimeoutInterval: 15000, random: false },
  specs: [ 'e2e/**/*.spec.*.js', 'e2e/**/*.spec.js' ] 
}

@balaarunreddyv1
Copy link

yes, this issue still occurs

@heathkit
Copy link
Contributor

This actually looks like a separate issue. I've opened #3881 to track it to avoid confusion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants