2016-01-13 76 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

謝謝救了我的時間;) –

相關問題