diff --git a/lib/configParser.js b/lib/configParser.js index fe8ab2f43..8ff2ed1a1 100644 --- a/lib/configParser.js +++ b/lib/configParser.js @@ -98,7 +98,7 @@ ConfigParser.resolveFilePatterns = for (var i = 0; i < patterns.length; ++i) { var matches = glob.sync(patterns[i], {cwd: cwd}); if (!matches.length && !opt_omitWarnings) { - log.puts('Warning: pattern ' + patterns[i] + ' did not match any files.'); + log.warn('pattern ' + patterns[i] + ' did not match any files.'); } for (var j = 0; j < matches.length; ++j) { resolvedFiles.push(path.resolve(cwd, matches[j])); @@ -164,7 +164,7 @@ ConfigParser.prototype.addConfig_ = function(additionalConfig, relativeTo) { // chromeOnly is deprecated, use directConnect instead. if (additionalConfig.chromeOnly) { - log.puts('Warning: chromeOnly is deprecated. Use directConnect'); + log.warn('chromeOnly is deprecated. Use directConnect'); additionalConfig.directConnect = true; } merge_(this.config_, additionalConfig); @@ -177,13 +177,22 @@ ConfigParser.prototype.addConfig_ = function(additionalConfig, relativeTo) { * @param {String} filename */ ConfigParser.prototype.addFileConfig = function(filename) { - if (!filename) { - return this; + try { + if (!filename) { + return this; + } + var filePath = path.resolve(process.cwd(), filename); + var fileConfig = require(filePath).config; + if (!fileConfig) { + log.error('configuration file ' + filename + ' did not export a config ' + + 'object'); + } + fileConfig.configDir = path.dirname(filePath); + this.addConfig_(fileConfig, fileConfig.configDir); + } catch (e) { + log.error('failed loading configuration file ' + filename); + throw e; } - var filePath = path.resolve(process.cwd(), filename); - var fileConfig = require(filePath).config; - fileConfig.configDir = path.dirname(filePath); - this.addConfig_(fileConfig, fileConfig.configDir); return this; }; diff --git a/lib/launcher.js b/lib/launcher.js index eea55c59c..cd989998d 100644 --- a/lib/launcher.js +++ b/lib/launcher.js @@ -111,6 +111,9 @@ var init = function(configFile, additionalConfig) { } var config = configParser.getConfig(); log.set(config); + log.debug('Running with --troubleshoot'); + log.debug('Protractor version: ' + require('../package.json').version); + log.debug('Your base url for tests is ' + config.baseUrl); var scheduler = new TaskScheduler(config); process.on('exit', function(code) { diff --git a/lib/logger.js b/lib/logger.js index ee2cb8e59..9bfca1869 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -23,11 +23,21 @@ var puts = function() { var debug = function(msg) { if (troubleshoot) { - puts(msg); + puts('DEBUG - ' + msg); } }; +var warn = function(msg) { + puts('WARNING - ' + msg); +} + +var error = function(msg) { + puts('ERROR - ' + msg); +} + exports.set = set; exports.print = print; exports.puts = puts; exports.debug = debug; +exports.warn = warn; +exports.error = error; diff --git a/lib/protractor.js b/lib/protractor.js index 1ec6eb436..67a70594f 100644 --- a/lib/protractor.js +++ b/lib/protractor.js @@ -703,9 +703,9 @@ var buildElementHelper = function(ptor) { elementArrayFinder.locator_.toString()); } else { if (webElements.length > 1) { - log.puts('warning: more than one element found for locator ' + + log.warn('more than one element found for locator ' + elementArrayFinder.locator_.toString() + - ' - you may need to be more specific'); + ' - the first result will be used'); } return [webElements[0]]; } diff --git a/lib/runner.js b/lib/runner.js index 6329d6354..4f075ea38 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -258,6 +258,13 @@ Runner.prototype.run = function() { }).then(function() { var browser = self.createBrowser(); self.setupGlobals_(browser); + return browser.getSession().then(function(session) { + log.debug('WebDriver session successfully started with capabilities ' + + util.inspect(session.getCapabilities())); + }, function(err) { + log.error('Unable to start a WebDriver session.'); + throw err; + }); // 3) Setup plugins }).then(function() { plugins = new Plugins(self.config_); diff --git a/lib/taskScheduler.js b/lib/taskScheduler.js index c80590f4c..1bc02ed9c 100644 --- a/lib/taskScheduler.js +++ b/lib/taskScheduler.js @@ -1,5 +1,5 @@ /** - * The taskScheduler keeps track of the specs that needs to run next + * The taskScheduler keeps track of the spec files that needs to run next * and which task is running what. */ 'use strict'; @@ -34,8 +34,9 @@ var TaskScheduler = function(config) { if (config.capabilities) { if (config.multiCapabilities.length) { - log.puts('Running using config.multiCapabilities - ' + - 'config.capabilities will be ignored'); + log.warn('You have specified both capabilites and ' + + 'multiCapabilities. This will result in capabilities being ' + + 'ignored'); } else { // Use capabilities if multiCapabilities is empty. config.multiCapabilities = [config.capabilities];