2017-09-25 76 views
0

我NightwatchJS測試工作正常,然後突然間,他們停止了工作,我得到這個錯誤:與NightwatchJS開始Selenium測試剛剛停止工作

Running: Google Simple Search Test 
Error processing the server response: 
The command 'POST /wd/hub/session' was not found. 

Error retrieving a new session from the selenium server 

Connection refused! Is selenium server started? 
{ value: -1, error: 'Unexpected token T in JSON at position 0' } 

我開始在一個新的文件夾新鮮和https://github.com/ChrisZie/nightwatch-boilerplate下載的測試項目,給出了完全相同的響應,這使得我認爲這是本地的一些問題:)

我試圖谷歌的錯誤,但無法找到任何答案。

const seleniumServer = require('selenium-server'); 
const chromedriver = require('chromedriver'); 
const geckodriver = require('geckodriver'); 
const phantomjs = require('phantomjs-prebuilt'); 
const dockerSeleniumHub = 'seleniumhub'; 
const argv = require('yargs').argv; 


if (argv.cucumber) { 
    require('nightwatch-cucumber')({ 
     cucumberArgs: ['--require', 'timeout.js', '--require', 'features/step_definitions', '--format', 'pretty', '--format', 'json:features/reports/cucumber.json', 'features'] 
    }); 
} 
module.exports = { 
    selenium : { 
     start_process : true, 
     server_path : seleniumServer.path, 
     log_path : '' , 
     selenium_host : '127.0.0.1', 
     selenium_port : 4444, 
     cli_args : { 
      'webdriver.chrome.driver' : chromedriver.path, 
      'webdriver.gecko.driver' : geckodriver.path, 
      'webdriver.ie.driver' :'' , 
      'webdriver.firefox.profile':'' 
     } 
    }, 
    test_settings : { 
     default : { 
      launch_url : 'https://www.google.com', 
      silent : true, 
      disable_colors: false, 
      screenshots: { 
       enabled: true, 
       on_failure: true, 
       on_error: false, 
       path: 'screenshoots/' // relativ to src directory 
      }, 
      desiredCapabilities : { 
       browserName : 'chrome', 
       javascriptEnabled : true, 
       acceptSslCerts : true, 
       'phantomjs.binary.path': phantomjs.path 
      }, 
     }, 
     chrome: { 
      desiredCapabilities: { 
       browserName: 'chrome', 
       javascriptEnabled: true, 
       acceptSslCerts: true 
      } 
     }, 

     firefox: { 
      desiredCapabilities: { 
       browserName: 'firefox', 
       javascriptEnabled: true, 
       acceptSslCerts: true 
      } 
     }, 
     phantomjs: { 
      desiredCapabilities: { 
       browserName: 'phantomjs', 
       javascriptEnabled: true, 
       acceptSslCerts: true, 
       'phantomjs.binary.path': phantomjs.path 
      } 
     }, 
     local_docker:{ 
      selenium_host: dockerSeleniumHub, 
      selenium_port: 4444, 
      start_process : false, 
      desiredCapabilities: { 
       browserName: 'firefox' 
      } 
     }, 
     mocha: { 
      test_runner: { 
       type: 'mocha', 
       options: { 
        ui: 'bdd', 
        reporter: 'list' 
       } 
      } 
     } 
    } 
}; 

回答

0

我想通了什麼是錯的,併發布在這裏,因爲我找不到答案。

我的問題是使用相同的端口,所以我檢查使用

lsof -i tcp:4444 

然後我用

kill -quit <PID> 

和現在的作品已經有一些服務!