1

I setup my protractor with this conf file below:

exports.config = {
  framework: 'mocha',
  rootElement: '#container1',
  specs: ['*container1_spec.js'],
  capabilities: {
    browserName: 'chrome',
    version: '',
    platform: 'ANY'
  },
  onPrepare: function() {
    // implicit and page load timeouts
    browser.manage().timeouts().pageLoadTimeout(40000);
    browser.manage().timeouts().implicitlyWait(25000);
  }
}

The application is manually bootstrapped in angular and I need to change the root element after some steps when the application transfers the control to another application by doing a window.location.replace. The second application that starts is also an angular app which does manual bootstrapping.

From another thread in SO. I found the code that I could do browser.rootEl = 'div#container2';

WebDriverError: unknown error: [ng:test] no injector found for element argument to getTestability
http://errors.angularjs.org/1.5.8/ng/test 
Community
  • 1
  • 1
randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72

1 Answers1

1

As I mentioned in the question, changing the rootEl did not work. I had to resort to working with the DOM to run the tests.

function getMessage() {
  return document.getElementById('msg').textContent;
}
setTimeout(function() {
  browser.executeScript(getMessage).then(function (txt) {
    chai.expect(txt).to.equal("Error occured");
    done();
  });
}, 10000);

browser.executeScript is the key function that allowed me to query DOM and workaround. I had to add a timeout for the lag to allow the second application to download and bootstrap.

randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72