量angular器在PhantomJS上运行testing

我似乎无法成功通过testingPhantomJS。 我试图将其整合到我的项目中,但之后失败了,我试图运行基本的Angular Docs样本,并得到同样的问题。 我到目前为止的步骤:

  • npm install -g phantomjs
  • phantomjs --webdriver=9515 // … GhostDriver – Main – 在端口9515上运行
  • protractor protractorConf.js

这是与仅有browserName和seleniumAddress端口更改相同的文件:

 // An example configuration file. exports.config = { // The address of a running selenium server. seleniumAddress: 'http://localhost:9515', // Capabilities to be passed to the webdriver instance. capabilities: { 'browserName': 'phantomjs' }, // Spec patterns are relative to the current working directly when // protractor is called. specs: ['onProtractorRunner.js'], // Options to be passed to Jasmine-node. jasmineNodeOpts: { showColors: true, } }; 

我收到以下错误信息:

 UnknownError: Error Message => 'Detected a page unload event; asynchronous script execution does not work across page loads.' 

我在github上发现了这个问题 ,这似乎是相关的。 我以为我已经对他们的brower-setup.md有足够的理解,把它包含在我beforeEach函数中。 然后我发现这里 ptor只是包装司机。 哇,我知道我在量angular器/selenium地这里是一个小菜鸟,但是信噪比是很强的劝阻。 我真的很想获得使用PhantomJS的性能优势,但是在这方面又损失了几个小时的前景令我头痛不已。 我在Windows 7企业版64位,以防万一。 谢谢!

Acutally这个修复程序是为我解决同样的问题:

https://github.com/pschwartau/protractor/commit/1eeff8b1b2e3e8f3b7c8152264411f26d4665a07

正如最初描述的那样: https : //github.com/angular/protractor/issues/85#issuecomment-26846255作者:renanmartins


量angular器内部/ lib / protractor.jsreplace

 this.driver.get('about:blank'); this.driver.executeScript( 'window.name = "' + DEFER_LABEL + '" + window.name;' + 'window.location.href = "' + destination + '"'); 

  var driver = this.driver; this.getCapabilities().then(function (capabilities) { if (capabilities.caps_.browserName === 'phantomjs') { driver.executeScript('window.name = "' + DEFER_LABEL + '" + window.name;'); driver.get(destination); } else { driver.get('about:blank'); driver.executeScript( 'window.name = "' + DEFER_LABEL + '" + window.name;' + 'window.location.href = "' + destination + '"'); } // Make sure the page is an Angular page. driver.executeAsyncScript(clientSideScripts.testForAngular, 10). then(function(hasAngular) { if (!hasAngular) { throw new Error('Angular could not be found on the page ' + destination); } }); });