为什么错误Connection拒绝了! selenium服务器是否已启动?

时间:2018-02-02 11:23:23

标签: selenium nightwatch.js

在完成以下操作后尝试运行夜班:https://github.com/dwyl/learn-nightwatch。这是我的配置文件:

//require('env2')('.env'); // optionally store youre Evironment Variables in .env
const seleniumServer = require("selenium-server");
//const chromedriver = require("chromedriver");
const SCREENSHOT_PATH = "./screenshots/";

// we use a nightwatch.conf.js file so we can include comments and helper functions
module.exports = {
    "src_folders": [
        "tests/"// Where you are storing your Nightwatch e2e tests
    ],
    "output_folder": "./reports", // reports (test outcome) output by nightwatch
    "selenium": {
        "start_process": true, // tells nightwatch to start/stop the selenium process
        "server_path": seleniumServer.path,
        "host": "127.0.0.1",
        "port": 4444, // standard selenium port
        "cli_args": {
            "webdriver.chrome.driver": "./chromedriver.exe"
        }
    },
    "test_settings": {
        "default": {
            "screenshots": {
                "enabled": true, // if you want to keep screenshots
                "path": './screenshots' // save screenshots here
            },
            "globals": {
                "waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
            },
            "desiredCapabilities": { // use Chrome as the default browser for tests
                "browserName": "chrome"
            }
        },
        "chrome": {
            "desiredCapabilities": {
                "browserName": "chrome",
                "javascriptEnabled": true // turn off to test progressive enhancement
            }
        }
    }
}

function padLeft(count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
    return count < 10 ? '0' + count : count.toString();
}

var FILECOUNT = 0; // "global" screenshot file count
/**
 * The default is to save screenshots to the root of your project even though
 * there is a screenshots path in the config object above! ... so we need a
 * function that returns the correct path for storing our screenshots.
 * While we're at it, we are adding some meta-data to the filename, specifically
 * the Platform/Browser where the test was run and the test (file) name.
 */
function imgpath(browser) {
    var a = browser.options.desiredCapabilities;
    var meta = [a.platform];
    meta.push(a.browserName ? a.browserName : 'any');
    meta.push(a.version ? a.version : 'any');
    meta.push(a.name); // this is the test filename so always exists.
    var metadata = meta.join('~').toLowerCase().replace(/ /g, '');
    return SCREENSHOT_PATH + metadata + '_' + padLeft(FILECOUNT++) + '_';
}

module.exports.imgpath = imgpath;
module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH;

当我运行nightwatch --config conf.js时,我收到此错误:

Starting selenium server... started - PID:  6296

[Go] Test Suite
===================

Running:  Guinea Pig Assert Title

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started?
{ value:
   { message: 'Unable to create new service: ChromeDriverService\nBuild info: version: \'3.8.1\', revision: \'6e95a6684b\', time: \'2017-12-01T19:05:32.194Z\'\nSystem info: host: \'S0026COW1983\', ip: \'10.39.13.81\', os.name: \'Windows Server 2008 R2\', os.arch: \'x86\', os.version: \'6.1\', java.version: \'1.8.0_131\'\nDriver info: driver.version: unknown',
     error: 'session not created' },
  status: 33 }

1 个答案:

答案 0 :(得分:0)

此行md5_hashed_email_address = Digest::MD5.hexdigest("john.doe@example.com") 指向zip文件,您需要解压缩内容并指向"webdriver.chrome.driver": "chromedriver_Win32.zip"文件。

相关问题