How can I run karma webdriver to use my selenium server / grid

Can anyone help shed some light on what is stopping the Karma javacript test runner from connecting to my selenium or selenium server?

I have a successfully working selenium selenium environment that I already use with selenium python bindings to test a web application system. I am currently running Selenium Server v.2.34.0, and 4 separate grid nodes are connected to it.

I want to also use and reuse this resource for testing javascript for multiple browsers. In particular, I am using node.js test drive based on jasmine based testing. I installed the karma-webdriver-launcher plugin . "I can run my javascript tests with karma locally creating firefox, chrome or IE browsers.

When I try to use a remote selenium server to use a browser from a pool / farm, it cannot find the browser, and I get the following warning output:

DEBUG [config]: autoWatch set to false, because of singleRun
DEBUG [plugin]: Loading karma-* from C:\nodedebug\itpt\node_modules
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-html-reporter.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-ie-launcher.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-typescript-preprocessor.
DEBUG [plugin]: Loading plugin C:\nodedebug\itpt\node_modules/karma-webdriver-launcher.
DEBUG [plugin]: Loading inlined plugin (defining launcher:firefox).
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser firefox via Remote WebDriver

WARN [launcher]: firefox via Remote WebDriver have not captured in 60000 ms, killing.
Killed Karma test.

, , , , wd. javascript node , - . , , , URL-, , .

- -webdriver-launcher\ node_modules\wd\lib\webdriver.js 33,

this._request(httpOpts, function(err, res, data) {

karma.config.js: -

// Karma configuration
module.exports = function (config) {
var webdriverConfig = {
  hostname: '172.17.126.52',
  port: 9625
}
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
    'Scripts/Libs/JsResources.js',

  // watch every ts file
  'Scripts/Local/**/*.ts'
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
    '**/*.ts': ['typescript']
},

typescriptPreprocessor: {
    // options passed to the typescript compiler
    options: {
        target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5'
    }
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots', 'html'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

customLaunchers: {
    'firefox': {
        base: 'WebDriver',
        config: webdriverConfig,
        browserName: 'firefox',
    }
},
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['firefox'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
};
+4
1

. .

1st Fix: karma.conf.js IP- , ( ). IP- .

config.set({
...
hostname: '172.123.123.123',
...
})

2nd Fix: package.json devDependencies.

"karma-webdriver-launcher": "~0.2.0",

, package.json : -

{
  "name": "MyKarmaProject",
  "devDependencies": {
    "karma": "~0.12.16",
    "karma-chrome-launcher": "~0.1.4",
    "karma-firefox-launcher": "~0.1.3",
    "karma-html-reporter": "^0.2.3",
    "karma-ie-launcher": "~0.1.5",
    "karma-webdriver-launcher": "~0.2.0",
    "karma-jasmine": "^0.2.2",
    "karma-phantomjs-launcher": "^0.1.4",
    "karma-typescript-preprocessor": "0.0.7",
    "phantomjs": "^1.9.7-12"
  }
}

, cmd prompt "npm install" package.json, , . , node. , - !

+9

Source: https://habr.com/ru/post/1548031/


All Articles