2016-01-13 156 views
2

我正在阅读Angular tutorial,并在第一章中介绍了如何运行unit和e2e测试。在教程中他们使用Chrome和Firefox。由于我在没有GUI的Ubuntu 14虚拟机上运行应用程序,因此我决定使用Phantomjs浏览器。e2e使用Phantom.js进行量角器测试

最终我能够用Phantom运行单元测试,但是我遇到了e2e问题。

这是量角器,conf.js的样子:

exports.config = { 
allScriptsTimeout: 11000, 

specs: [ 
'e2e/*.js' 
], 

    capabilities: { 
    'browserName': 'phantomjs', 
    'phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs', 
    'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG'] 
    }, 

    chromeOnly:true, 

    baseUrl: 'http://localhost:8000/', 

    framework: 'jasmine', 

    jasmineNodeOpts: { 
defaultTimeoutInterval: 30000 
} 
}; 

但是当我运行测试存在以下错误:

Starting selenium standalone server... 
[launcher] Running 1 instances of WebDriver 
[launcher] Process exited with error code 1 

events.js:72 
    throw er; // Unhandled 'error' event 
     ^
Error: spawn ENOENT 
at errnoException (child_process.js:988:11) 
at Process.ChildProcess._handle.onexit (child_process.js:779:34) 
npm ERR! weird error 8 
npm WARN This failure might be due to the use of legacy binary "node" 
npm WARN For further explanations, please read 
/usr/share/doc/nodejs/README.Debian 

npm ERR! not ok code 0 

我错过了在配置上的东西吗?在这种情况下如何获得更详细的错误描述?

+0

什么版本的节点是你使用'节点 - 版本'和什么版本的量角器? – martin770

+0

可能相关:http://stackoverflow.com/questions/21072439/protractor-0-16-1-e2e-angularjs-starting-selenium-standalone-server-events。 – alecxe

+0

@ martin770节点版本是v0.10.25。量角器版本是2.5.1。 – Tamara

回答

2

这个特殊的问题(奇怪的错误8)可以通过安装Java来解决:

sudo apt-get install openjdk-7-jdk 

但是,我还是不能,因为发生的另一个问题运行测试。在我的情况是:

UnknownError: Error communicating with the remote browser. It may have died. 

它看起来像使用phantomjs是一个铺成的道路折磨,也许我应该尝试使用Firefox与像@ martin770 xvfb的建议。


UPD

这个职位可能也有帮助,如果你在一个问题垂死phantom.js https://gist.github.com/tfnico/8471223

用户barzik建议将以下命令添加到beforeEach运行:

browser.ignoreSynchronization = true; 
browser.get('/'); //or any page you are going to test 
browser.waitForAngular(); 
+0

谢谢救了我的时间;) –

相关问题