1

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
Tielman Nieuwoudt
  • 903
  • 1
  • 12
  • 24
  • Could you check the following: 1. move `browser.driver.get('http://localhost:8100');` from `onPrepare` to your test - into the `describe`; 2. replace `browser.driver.get('http://localhost:8100');` with `browser.get('http://localhost:8100');`? Thanks. – alecxe Jun 10 '15 at 11:26
  • Removing the .driver from the browser.driver.get causes any test to fail immediately whether the .get call is made in onPrepare or in Describe, even if I don't reference the second browser instance. I'll look into how I can call the .driver on the second instance. – Tielman Nieuwoudt Jun 10 '15 at 15:13
  • Calling browser2.driver.get('http://localhost:8100') solves the problem! Hoorah. Thanks for point me in a direction. – Tielman Nieuwoudt Jun 10 '15 at 15:16
  • Perhaps you would like to run instances one after the other? See: http://stackoverflow.com/q/22009321/3049002 – glepretre Jun 10 '15 at 17:48

0 Answers0