Skip to content

Instantly share code, notes, and snippets.

@sotaan
Last active October 5, 2016 12:16
Show Gist options
  • Save sotaan/a3c06fabaed28ae2ca0e to your computer and use it in GitHub Desktop.
Save sotaan/a3c06fabaed28ae2ca0e to your computer and use it in GitHub Desktop.
wdio error with webdriverajax
$ wdio
=======================================================================================
Selenium 2.0/webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/docs.html.
=======================================================================================
[16:02:56]: COMMAND POST "/wd/hub/session"
[16:02:56]: DATA {"desiredCapabilities":{"browserName":"chrome","version":"","javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"platform":"ANY","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"3.4.0","name":"webdriverio"}}}
[16:02:57]: SET SESSION ID 31cee978-90ff-4088-90b3-627c9840be2b
[16:02:57]: RESULT {"applicationCacheEnabled":false,"rotatable":false,"mobileEmulationEnabled":false,"chrome":{"chromedriverVersion":"2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4)","userDataDir":"/var/folders/s4/gk0rbt_d2tj6tl60k6zgym1w0000gn/T/.org.chromium.Chromium.IT0JEp"},"takesHeapSnapshot":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"version":"48.0.2564.116","platform":"MAC","browserConnectionEnabled":false,"nativeEvents":true,"acceptSslCerts":true,"webdriver.remote.sessionid":"31cee978-90ff-4088-90b3-627c9840be2b","locationContextEnabled":true,"webStorageEnabled":true,"browserName":"chrome","takesScreenshot":true,"javascriptEnabled":true,"cssSelectorsEnabled":true}
ERROR: Unexpected identifier
browserName: "chrome"
Syntax at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.exports.config.before (/Users/socianova/Desktop/dev/wdio-testiris/wdio.conf.js:141:27)
at Object.exports.run (/Users/socianova/.nvm/versions/node/v4.2.4/lib/node_modules/webdriverio/lib/frameworks/jasmine.js:131:14)
at Object.<anonymous> (/Users/socianova/.nvm/versions/node/v4.2.4/lib/node_modules/webdriverio/lib/runner.js:153:38)
ERROR: Unexpected identifier
browserName: "chrome"
undefined: Unexpected identifier
[16:02:57]: COMMAND DELETE "/wd/hub/session/31cee978-90ff-4088-90b3-627c9840be2b"
[16:02:57]: DATA {}
[16:02:58]: RESULT null
exports.config = {
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
// directory is where your package.json resides, so `wdio` will be called from there.
//
specs: [
'./test/specs/**/*.js'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilties at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude option in
// order to group specific specs to a specific capability.
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
capabilities: [{
browserName: 'chrome'
}],
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: silent | verbose | command | data | result | error
logLevel: 'verbose',
//
// Enables colors for log output.
coloredLogs: true,
//
// Saves a screenshot to a given path if a command fails.
screenshotPath: './errorShots/',
//
// Set a base URL in order to shorten url command calls. If your url parameter starts
// with "/", the base url gets prepended.
baseUrl: 'https://mamadavisbx.socianova.net/212000_test',
//
// Default timeout for all waitForXXX commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if Selenium Grid doesn't send response
connectionRetryTimeout: 90000,
//
// Default request retries count
connectionRetryCount: 3,
//
// Initialize the browser instance with a WebdriverIO plugin. The object should have the
// plugin name as key and the desired plugin options as property. Make sure you have
// the plugin installed before running any tests. The following plugins are currently
// available:
// WebdriverCSS: https://github.com/webdriverio/webdrivercss
// WebdriverRTC: https://github.com/webdriverio/webdriverrtc
// Browserevent: https://github.com/webdriverio/browserevent
// plugins: {
// // webdrivercss: {
// // screenshotRoot: 'my-shots',
// // failedComparisonsRoot: 'diffs',
// // misMatchTolerance: 0.05,
// // screenWidth: [320,480,640,1024]
// // },
// // webdriverrtc: {},
// // browserevent: {}
// //webdriverajax: {}
// },
//
// Test runner services
// Services take over a specfic job you don't want to take care of. They enhance
// your test setup with almost no self effort. Unlike plugins they don't add new
// commands but hook themself up into the test process.
// services: [],//
// Framework you want to run your specs with.
// The following are supported: mocha, jasmine and cucumber
// see also: http://webdriver.io/guide/testrunner/frameworks.html
//
// Make sure you have the wdio adapter package for the specific framework installed
// before running any tests.
framework: 'jasmine',
//
// Test reporter for stdout.
// The following are supported: dot (default), spec and xunit
// see also: http://webdriver.io/guide/testrunner/reporters.html
// reporters: ['dot'],
//
// Options to be passed to Jasmine.
jasmineNodeOpts: {
//
// Jasmine default timeout
defaultTimeoutInterval: 20000,
//
// The Jasmine framework allows it to intercept each assertion in order to log the state of the application
// or website depending on the result. For example it is pretty handy to take a screenshot everytime
// an assertion fails.
expectationResultHandler: function(passed, assertion) {
// On prend une screenshot si l'assertion testee echoue.
if(passed) {
return;
}
//console.log(assertion);
var title = assertion.message.replace(/\s/g, '-');
browser.saveScreenshot('./assertionErrors/error-'+title+'.png');
}
},
//
// =====
// Hooks
// =====
// WedriverIO provides a several hooks you can use to intefere the test process in order to enhance
// it and build services around it. You can either apply a single function to it or an array of
// methods. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
//
// Gets executed once before all workers get launched.
// onPrepare: function (config, capabilities) {
// },
//
// Gets executed before test execution begins. At this point you can access to all global
// variables like `browser`. It is the perfect place to define custom commands.
before: function (capabilties, specs) {
var l = require('lodash');
var ext_fn = require('./env_loader/ext_functions.js');
var ExtQ = ext_fn.ExtQ;
var ExtButton = ext_fn.ExtButton;
var loadEnv = require('./env_loader/env.js').loadEnv;
//Rajoute la commande 'getIdFromExtName' a notre objet browser.
//Cette fonction injecte la fonction ExtQ, l'execute avec son argument
//et retourne le resultat
//`name` est toujours le nom du champ dans le model
browser.addCommand('getIdFromExtName', function(name){
return this.execute(ExtQ, name).then(function(ret){
return ret.value;
});
});
browser.addCommand('getButtonIdFromText', function(text){
return this.execute(ExtButton, text).then(function(ret){
return ret.value;
});
});
//On charge les fonctions retourner par `loadEnv`
//dans l'objet browser de WebdriverIO
browser.addCommand('loadEnv', loadEnv);
browser.loadEnv().then(function(fn){
l.forEach(fn, function(f, k){
this.addCommand(k.toString(), f);
}.bind(this));
});
},
// Hook that gets executed before the suite starts
// beforeSuite: function (suite) {
// },
//
// Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
// beforeEach in Mocha)
// beforeHook: function () {
// },
//
// Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
// afterEach in Mocha)
// afterHook: function () {
// },
//
// Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
// beforeTest: function (test) {
// },
//
// Runs before a WebdriverIO command gets executed.
// beforeCommand: function (commandName, args) {
// },
//
// Runs after a WebdriverIO command gets executed
// afterCommand: function (commandName, args, result, error) {
// },
//
// Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
// afterTest: function (test) {
// },
//
// Hook that gets executed after the suite has ended
// afterSuite: function (suite) {
// },
//
// Gets executed after all tests are done. You still have access to all global variables from
// the test.
// after: function (capabilties, specs) {
// },
//
// Gets executed after all workers got shut down and the process is about to exit. It is not
// possible to defer the end of the process using a promise.
// onComplete: function(exitCode) {
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment