角度E2E - 硒/量角器配置错误

时间:2017-02-09 00:59:00

标签: angularjs selenium protractor

我尝试使用量角器进行某些e2e测试,之前从未使用过它。该项目是使用yeoman-gulp-angular生成的,并且有一些预定义的测试任务/配置。当我尝试执行任务时,我看到selenium已经启动,然后堆栈跟踪在selenium关闭之前输出一些错误。配置中是否缺少某些内容?

量角器配置

'use strict';

var paths = require('./.yo-rc.json')['generator-gulp-angular'].props.paths;

// An example configuration file.
exports.config = {
  // The address of a running selenium server.
  //seleniumAddress: 'http://localhost:4444/wd/hub',
  //seleniumServerJar: deprecated, this should be set on node_modules/protractor/config.json

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

  // Spec patterns are relative to the current working directly when
  // protractor is called.
  specs: [paths.e2e + '/**/*.js'],

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

堆栈跟踪

Starting selenium standalone server...
(node:23800) DeprecationWarning: util.puts is deprecated. Use console.log instead.
Selenium standalone server started at http://[IP]/wd/hub

   Stacktrace:
     UnknownError: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"23817.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=56.0.2924.87)
  (Driver info: chromedriver=2.12.301326 (093c7e07b4a916b690e784b0374c7f618f1ea4be),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
...
   Stacktrace:
     UnknownError: Error communicating with the remote browser. It may have died.
...
Finished in 4.84 seconds
2 tests, 4 assertions, 4 failures

Shutting down selenium standalone server.

修改

[launcher] Error: UnknownError: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
xpi","e":true,"v":"1.7","st":1486662567000},"firefox@getpocket.com":{"d":"/Applications/Firefox.app/Contents/Resources/browser/features/firefox@getpocket.com.xpi","e":true,"v":"1.0.5","st":1486662567000},"webcompat@mozilla.org":{"d":"/Applications/Firefox.app/Contents/Resources/browser/features/webcompat@mozilla.org.xpi","e":true,"v":"1.0","st":1486662567000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","e":true,"v":"51.0.1","st":1486662567000}}}

更新

我认为事情是固定的,但事实并非如此。运行webdriver-manager update然后webdriver-manager status后,我看到chromedriver version available: 2.27 [last]。当我查看node_modules / protractor / selenium时,我看到chromedriver_2.12.zip。在node_modules / protractor / config.json中,我将chromedriver的webdriverVersions从2.12更改为2.27,这是不可用的。不确定我应该在protractor /config.json中指定哪个版本。

test-mbp:fota-admin-portal test$ gulp protractor:src
[11:48:17] Starting 'webdriver-update'...
selenium standalone is up to date.
Updating chromedriver
downloading https://chromedriver.storage.googleapis.com/2.27/chromedriver_mac32.zip...
Error: Got code 404 from https://chromedriver.storage.googleapis.com/2.27/chromedriver_mac32.zip
chromedriver_2.27.zip downloaded to /Users/test/project/node_modules/protractor/selenium/chromedriver_2.27.zip

/Users/test/project/node_modules/adm-zip/adm-zip.js:19
           throw Utils.Errors.INVALID_FILENAME;
           ^
Invalid filename

堆栈跟踪

   Stacktrace:
     UnknownError: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"26574.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=56.0.2924.87)
  (Driver info: chromedriver=2.12.301326 (093c7e07b4a916b690e784b0374c7f618f1ea4be),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)

2 个答案:

答案 0 :(得分:2)

您拥有的chromedriver版本相当陈旧,并且与最新的Chrome版本不兼容 - 您有56个

查看Protractor ChangeLog了解chromedriver最新版本的详细信息

运行webdriver-manager update以获取最新的驱动程序,这应解决问题

您还可以查看chromium site chromedriver vs Chrome兼容性

  

最新发布:ChromeDriver 2.27支持Chrome v54-56此版本   修复了导致ChromeDriver在页面上失败的错误   SharedWorkers。

答案 1 :(得分:0)

从命令提示符执行以下命令,从命令终端更新chrome驱动程序。

" webdriver-manager udpate"

Chrome驱动程序更新后,您将能够毫无问题地运行案例。

注意 - 使用" webdriver-manager status"查看驱动程序的版本详细信息。

如果您有任何问题,请与我们联系。