2017-01-12 110 views
0

這裏是我的nightwatch.json看起來像geckodriver與nightwatch.js

{ 
    "src_folders" : ["tests"], 
    "output_folder" : "reports", 
    "custom_commands_path" : "", 
    "custom_assertions_path" : "", 
    "page_objects_path" : "", 
    "globals_path" : "./globals.js", 

    "selenium" : { 
    "start_process" : false 
    }, 

    "test_settings" : { 
    "default" : { 
     "launch_url" : "http://localhost", 
     "selenium_port" : 9515, 
     "selenium_host" : "localhost", 
     "silent": false, 
     "default_path_prefix": "", 
     "desiredCapabilities": { 
     "browserName": "firefox", 
     "javascriptEnabled": true, 
     "acceptSslCerts": true, 
     "marionette": true 
     } 
    } 
    } 
} 

,這裏是我的globals.js是什麼樣子:

var geckodriver = require('geckodriver'); 
module.exports = { 
    before : function(done) { 
    geckodriver.start(); 
    done(); 
    }, 

    after : function(done) { 
    geckodriver.stop(); 
    done(); 
    } 
}; 

當我運行nightwatch這裏就是發生:

▶ nightwatch 

[New] Test Suite 
======================== 

Running: login 
INFO Request: POST /session 
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true,"name":"New"}} 
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":148} 

Error retrieving a new session from the selenium server 

Connection refused! Is selenium server started? 
{ Error: connect ECONNREFUSED 127.0.0.1:9515 
    at Object.exports._errnoException (util.js:1022:11) 
    at exports._exceptionWithHostPort (util.js:1045:20) 
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14) 
    code: 'ECONNREFUSED', 
    errno: 'ECONNREFUSED', 
    syscall: 'connect', 
    address: '127.0.0.1', 
    port: 9515 } 

我試圖模擬什麼東西看起來像獨立的鉻設置,但我想我錯過了某些東西,或者有一個阻止事情繼續進行的錯誤。

回答

0

我沒有正確的端口設置,woops!我需要將selenium_port更改爲4444