Can't run Selenium via Protractor on Firefox a

2019-02-12 05:16发布

问题:

After updating Angular JS 1.4.x to Angular 2, Selenium tests can't run anymore via grunt-protractor-runner on Firefox. As soon as AngularJS is loaded, the following error occurs:

D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108
  var template = new Error(this.message);
                 ^
UnknownError: Permission denied to access property "toString"
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'NAGWS72', ip: '192.168.210.23', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
Driver info: driver.version: unknown
    at new bot.Error (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
    at Object.bot.response.checkResponse (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
    at D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
    at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
    at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
    at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
    at goog.async.run.processWorkQueue (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
    at process._tickCallback (node.js:366:9)
From: Task: <anonymous>
    at [object Object].pollCondition [as _onTimeout] (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2233:16)
    at Timer.listOnTimeout (timers.js:92:15)
From: Task: <anonymous wait>
    at [object Object].promise.ControlFlow.goog.defineClass.getSchedule.indent.wait (D:/.../node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2226:17)
    at [object Object].webdriver.WebDriver.wait (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:716:21)
    at [object Object].to.(anonymous function) [as wait] (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\protractor.js:65:25)
    at global.doLogin (D:\...\nisXplorerConfig.js:44:21)
    at exports.config.onPrepare (D:\...\nisXplorerConfig.js:79:9)
    at D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\util.js:54:41
    at Function.promise (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\q\q.js:650:9)
    at Object.exports.runFilenameOrFn_ (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\util.js:44:12)
    at [object Object].Runner.runTestPreparer (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\runner.js:76:17)
    at Object.exports.run (D:\...\node_modules\grunt-protractor-runner\node_modules\protractor\lib\frameworks\jasmine.js:89:17)

Chrome and Internet Explorer work fine.

The problem appears with the following components:

  • Firefox version 38 and 42
  • grunt-protractor-runner 2.1.0 and 3.0.0 (which uses selenium-server-standalone-2.48.2.jar)
  • protractor 2.5.1 and 3.0.0

The following node modules are in use (package.json):

{
  "name": "...",
  "version": "1.0.0",
  "description": "",
  "main": "Gruntfile.js",
  "dependencies": {
    "jasmine-reporters": "^2.0.7",
    "protractor-video-recorder": "^0.1.0"
  },
  "devDependencies": {
    "grunt-protractor-runner": "^3.0.0",
    "jasmine-spec-reporter": "^2.4.0",
    "lodash": "^3.10.1",
    "protractor-console": "^2.0.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

There is no code part in the Selenium test, which can be localized to produce the error. The error appears just at the moment when AngularJS is loaded.

回答1:

To isolate the problem I installed the sample Angular 2 Go with Protractor ! and got exactly the same error (as in my first comment) after I changed browserName: 'chrome' to firefox.

Thus I created a new issue on Protractors github page.



回答2:

See related tickets:

  • https://github.com/angular/protractor/issues/2784
  • https://github.com/SeleniumHQ/selenium/issues/1416

Based on the last comment on the selenium ticket:

Angular 2 is patching EventTarget.prototype, so they are responsible for any bugs caused by their changes.