2017-09-06 76 views
0

我在使用量角器開始端到端測試時遇到以下錯誤。量角器未啓動硒

[email protected]:/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app$ ./node_modules/protractor/bin/protractor ./conf.js 
[16:29:47] I/launcher - Running 1 instances of WebDriver 
[16:29:47] I/direct - Using ChromeDriver directly... 
[16:29:47] E/launcher - EINVAL: invalid argument, uv_interface_addresses 
[16:29:47] E/launcher - Error: EINVAL: invalid argument, uv_interface_addresses 
    at Error (native) 
    at getLoInterface (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/selenium-webdriver/net/index.js:30:20) 
    at getAddress (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/selenium-webdriver/net/index.js:46:14) 
    at Object.exports.getLoopbackAddress (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/selenium-webdriver/net/index.js:85:10) 
    at resolveCommandLineFlags.then.args (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/selenium-webdriver/remote/index.js:240:24) 
    at process._tickCallback (internal/process/next_tick.js:109:7) 
From: Task: WebDriver.createSession() 
    at Function.createSession (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/selenium-webdriver/lib/webdriver.js:777:24) 
    at Function.createSession (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/selenium-webdriver/chrome.js:709:29) 
    at Direct.getNewDriver (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/lib/driverProviders/direct.ts:90:25) 
    at Runner.createBrowser (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/lib/runner.ts:225:39) 
    at q.then.then (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/lib/runner.ts:391:27) 
    at _fulfilled (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/q/q.js:834:54) 
    at self.promiseDispatch.done (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/q/q.js:863:30) 
    at Promise.promise.promiseDispatch (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/q/q.js:796:13) 
    at /mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/q/q.js:556:49 
    at runSingle (/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/q/q.js:137:13) 
[16:29:47] E/launcher - Process exited with error code 199 
[email protected]:/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app$ 

我可能是因爲啓動webdriver的問題。我試圖運行硒,但我得到了以下錯誤

[email protected]:/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app$ ./node_modules/protractor/bin/webdriver-manager start 
[16:27:55] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.32 -Dwebdriver.gecko.driver=/mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.18.0 -jar /mnt/c/Users/Manu/Documents/manu/programs/web/angular/dw-ng2-app/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.5.3.jar -port 4444 
[16:27:55] I/start - seleniumProcess.pid: undefined 
[16:27:55] W/start - Selenium Standalone server encountered an error: Error: spawn java ENOENT 

我已經試過清潔和使用cleanstart選項與webdriver的經理重新啓動,但尚未解決的問題

更新--- 我我通過Bash for Windows在Windows機器上運行它。啓動Selenium的問題是Bash無法找到Java。我導出了Path,但是因爲Java安裝在Program Files中,所以我無法在Bash中設置路徑,因爲Bash無法處理Program Files中的空間。我可以在設置了JAVA路徑的CMD上運行硒服務器。但問題仍然沒有解決。

回答

0

看來問題是我第一次沒有正確安裝。我應該從主目錄運行webdriver-manager update。我使用webdriver-manger clean進行清理,並從項目主目錄project home> .\node_modules\protractor\bin\webdriver-manager start重新運行webdriver-manger start。如果使用其他目錄,安裝可能會設置一些弄亂的路徑。我還從項目的主目錄開始量角器>node .\node_modules\protractor\bin\protractor .\protractor.conf.js

+0

如果您打算使用'directConnect'啓動,則需要確保項目的本地'node_modules/webdriver-manager/selenium'目錄中存在二進制文件。量角器正在尋找名爲'node_modules/webdriver-manager/selenium/update-config.json'的文件。當你做一個成功的'webdriver-manager更新'時,這個文件就會出現。量角器會發現你的ChromeDriver二進制文件(基於update-config.json),並且應該從那裏開始工作。除非你打算使用獨立的硒服務器,否則你不必調用'webdriver-manager start'。 。 – cnishina