Protractor: Multiple browser instance tests fail where Single Instance tests pass

826 views Asked by At

I'm testing an Ionic application. When the app is run in the browser, the console does show that cordova.js is missing - which is right, but it doesn't break the application.

As long as I run my tests with a single browser instance, the missing files does not cause my tests to fail. Here is my configuration and spec files:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine2',
  suites: {
    test: 'e2e/test.spec.js'
  },
  allScriptsTimeout: 60000,
  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
            binary: '/Applications/Google\ Chrome\ Stable.app/Contents/MacOS/Google\ Chrome',
            args: [],
            extensions: [],
        }
  },
  onPrepare: function() {
    browser.driver.get('http://localhost:8100');
  }
};

Here is the test file:

describe('First test', function(){
it('just verifies that everything loads correctly', function() {
      expect(1).toEqual(1);
  });
});

The above works without errors. But opening a second browser instance causes a fail:

describe('First test', function(){
  var browser2 = browser.forkNewDriverInstance();
  browser2.get('http://localhost:8100');
  var element2 = browser2.element;
it('just verifies that everything loads correctly', function() {
      expect(1).toEqual(1);
  });
});

With the error message:

/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
  var template = new Error(this.message);
                 ^
UnknownError: unknown error: cordova is not defined
0

There are 0 answers