Can anyone help shed some light on to what is stopping Karma javascript test runner from connecting to and using my selenium grid/server?
I have a successfully working selenium grid environment that I already use with python selenium bindings for web application system testing. I'm running Selenium Server v.2.34.0 currently and it has 4 separate grid nodes connected to it.
I want to also leverage and reuse this resource for javascript testing against multiple browsers. Specifically I'm using the node.js based Karma test runner executing jasmine based unit tests. I've installed the "karma-webdriver-launcher" plugin. I can run my javascript tests with karma locally spawning firefox, chrome or IE browsers just fine.
When I try to use the remote selenium server to use a browser from the pool/farm, it fails to find a 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.
When I runtime debug the karma-webdriver-launcher stepping through it, it seems to fail in the wd request. My node javascript skills are only at a beginner level though so I might be missing something obvious. All the config details seemed to be getting passed correctly though and the url used for connecting to the selenium server look correct to me.
It fails inside this call of karma-webdriver-launcher\node_modules\wd\lib\webdriver.js on line 33,
this._request(httpOpts, function(err, res, data) {
Here's my karma.config.js file:-
// 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
});
};