量角器:单实例测试通过

时间:2015-06-10 11:15:40

标签: angularjs cordova integration protractor ionic

我正在测试Ionic应用程序。当应用程序在浏览器中运行时,控制台确实显示缺少cordova.js - 这是正确的,但它不会破坏应用程序。

只要我使用单个浏览器实例运行测试,丢失的文件就不会导致我的测试失败。这是我的配置和规范文件:

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');
  }
};

这是测试文件:

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

以上工作没有错误。但是打开第二个浏览器实例会导致失败:

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);
  });
});

显示错误消息:

/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 个答案:

没有答案