更新到 Angular 2 后,无法在 Firefox 上通过 Protractor 运行 Selenium
Posted
技术标签:
【中文标题】更新到 Angular 2 后,无法在 Firefox 上通过 Protractor 运行 Selenium【英文标题】:Can't run Selenium via Protractor on Firefox after update to Angular 2 【发布时间】:2016-03-17 05:07:23 【问题描述】:将 Angular JS 1.4.x 更新到 Angular 2 后,Selenium 测试无法再通过 Firefox 上的 grunt-protractor-runner 运行。一旦加载 AngularJS,就会发生以下错误:
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 和 Internet Explorer 工作正常。
问题出现在以下组件中:
Firefox 版本 38 和 42 grunt-protractor-runner 2.1.0 和 3.0.0(使用 selenium-server-standalone-2.48.2.jar) 量角器 2.5.1 和 3.0.0以下节点模块正在使用中(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"
Selenium 测试中没有代码部分,可以本地化产生错误。该错误仅在加载 AngularJS 时出现。
【问题讨论】:
您能在任何公共 angular2 网站上重现该问题吗? (比如说,angular.io)。谢谢。 另外,你试过directConnect
吗?
感谢您的回答,@alecxe。我刚刚尝试过: - 针对 angular.io 进行测试可以正常工作。 - directConnect
产生完全相同的错误这是我的配置:> options: > configFile: "....js", > args: > directConnect: true, > baseUrl: "...", > capabilities: > 'browserName': 'firefox', > 'browser': 'Firefox' > , > specs: [ > 'testFiles/....js' > ], > >
感谢您的测试。因此,我们可以假设这是特定于应用程序的,并且可能与您如何引导 angular...
非常感谢!我会审查的。
【参考方案1】:
查看相关票证:
https://github.com/angular/protractor/issues/2784 https://github.com/SeleniumHQ/selenium/issues/1416基于对 selenium 票的最后评论:
Angular 2 正在修补 EventTarget.prototype,因此他们对由其更改引起的任何错误负责。
【讨论】:
【参考方案2】:为了隔离问题,我安装了示例Angular 2 Go with Protractor !,并在将browserName: 'chrome'
更改为firefox
后得到了完全相同的错误(与我的第一条评论中一样)。
因此,我在 Protractors github 页面上创建了一个 new issue。
【讨论】:
太棒了,现在重现了这个问题。谢谢。以上是关于更新到 Angular 2 后,无法在 Firefox 上通过 Protractor 运行 Selenium的主要内容,如果未能解决你的问题,请参考以下文章
Angular 10 PWA 中 Chrome 更新后的新警告“无法安装站点:页面无法脱机工作。从 Chrome 93 开始...”
从Angular 5更新到6后,我不断收到错误:无法解析xml2js中的计时器