量角器运行测试上PhantomJS [英] Protractor running tests on PhantomJS
问题描述
我似乎无法通过测试获得成功PhantomJS。我试图把它融入我的项目,但之后未能我想只是运行基本角文档样本,我得到了同样的问题。我的步骤到目前为止:
I can't seem to get PhantomJS through a test successfully. I tried to integrate it into my project, but after that failed I tried to just run the basic Angular Docs samples and I'm getting the same issue. My steps so far:
-
NPM安装-g phantomjs
-
phantomjs --webdriver = 9515
// ... GhostDriver - 主 - 在端口9515上运行 -
量角器protractorConf.js
npm install -g phantomjs
phantomjs --webdriver=9515
// ... GhostDriver - Main - running on port 9515protractor protractorConf.js
这是从实施例相同的文件只有browserName和seleniumAddress端口改变:
This is the same file from the example with only browserName, and seleniumAddress port changed:
// 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,
}
};
我收到以下错误信息:
I get the following error message:
UnknownError: Error Message => 'Detected a page unload event; asynchronous script execution does not work across page loads.'
我发现这个问题在github ,这似乎是相关的。我想我做了他们的<足够感href=\"https://github.com/angular/protractor/blob/master/docs/browser-setup.md#appendix-a-using-with-the-protractor-library\">brower-setup.md把它列入我的 beforeEach
功能之一。后来我发现这里 ptor
只是包装司机反正。哇,我知道我在这里就是一个小白在量角器/硒的土地,但信噪比为深入劝诫。我真的很想得到使用PhantomJS的性能优势,但失去对这个几个小时的前景是伤害我的头。我在Windows 7企业版64位,在这种情况下,重要的。谢谢!
I found this issue on github, which seemed to be related. I thought I had made enough sense of their brower-setup.md to include it in one of my beforeEach
functions. Then I found here ptor
is just wrapping the driver anyway. Wow, I know I'm a noob here in protractor/selenium land, but the signal to noise ratio is intensively dissuasive. I'd really like to get the performance benefits of using PhantomJS, but the prospect of losing several more hours on this is hurting my head. I'm on Windows 7 Enterprise 64-bit, in case that matters. Thanks!
推荐答案
NOTE:事实上此修复程序解决同一个问题对我来说:
Acutally this fix was solving the same issue for me:
的https://github.com/pschwartau/protractor/commit/1eeff8b1b2e3e8f3b7c8152264411f26d4665a07
由于这里最初描述: https://github.com/angular/protractor /问题/ 85#issuecomment-26846255 通过renanmartins
As originally described here: https://github.com/angular/protractor/issues/85#issuecomment-26846255 by renanmartins
在量角器/ lib中/ protractor.js替换
Inside protractor/lib/protractor.js Replace
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);
}
});
});
这篇关于量角器运行测试上PhantomJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!