当我没有针对浏览器时,为什么Protractor会抱怨目标浏览器配置?

时间:2015-03-12 17:04:43

标签: angularjs ionic-framework protractor appium saucelabs

我正在使用Ionic / Angular编写应用程序并使用Protractor进行测试。我想使用Sauselabs Appium进行测试,这样我就可以测试在各种目标平台上本机运行的应用程序。我正在推出Protractor:

SAUCE_USERNAME=$(SAUCE_USERNAME) SAUCE_ACCESS_KEY=$(SAUCE_ACCESS_KEY) ./node_modules/.bin/protractor protractorConfig.js

但我收到此错误消息:

[launcher] Running 1 instances of WebDriver
[launcher] Error: TypeError: Target browser must be a string, but is <object>; did you forget to call forBrowser()?

我的protractorConfig.js看起来像:

/* global exports */
/* global process */
exports.config = {
  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,
  capabilities: {
    appiumVersion: "1.0",
    app: "sauce-storage:app.zip",
    platformName: "iOS",
    platformVersion: "7.1",
    deviceName: "iPhone Simulator"
  },
  allScriptsTimeout: 30000,
  specs: [
    "spec/feature/*.js"
  ]
};

2 个答案:

答案 0 :(得分:2)

我应该更仔细地阅读文档。 Appium's documentation for Desired Capabilities说&#39; browserName&#39;如果您没有定位浏览器,则应为空字符串。

相应地更新我的protractorConfig解决了这个问题。

/* global exports */
/* global process */
exports.config = {
  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,
  capabilities: {
    appiumVersion: "1.0",
    app: "sauce-storage:app.zip",
    platformName: "iOS",
    platformVersion: "7.1",
    deviceName: "iPhone Simulator",
    browserName: ""
  },
  allScriptsTimeout: 30000,
  specs: [
    "spec/feature/*.js"
  ]
};

答案 1 :(得分:0)

尝试在您的功能中添加'browserName': 'chrome'