webdriverio: @wdio/local-runner: Failed launching test session: TypeError: Cannot read properties of undefined (reading 'init')
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
“webdriverio”: “^8.20.4”
Node.js Version
18.8
Mode
Standalone Mode
Which capabilities are you using?
chrome
What happened?
I updated my package. json with latest version of dependencies and the following error was thrown
Packasge.json
“dependencies”: { “@babel/cli”: “^7.2.3”, “@babel/plugin-proposal-export-default-from”: “^7.5.2”, “@babel/preset-env”: “^7.23.2”, “@babel/register”: “^7.4.0”, “@hapi/wreck”: “^18.0.1”, “@log4js-node/log4js-api”: “^1.0.2”, “@rpii/wdio-report-events”: “^0.2.0”, “@types/cucumber”: “^4.0.5”, “@wdio/browserstack-service”: “^8.6.0”, “@wdio/config”: “^5.11.0”, “@wdio/reporter”: “^7.25.0”, “@wdio/static-server-service”: “^5.14.4”, “axe-webdriverio”: “^0.2.0”, “browserstack-local”: “^1.4.8”, “chai”: “^4.1.2”, “constants”: “^0.0.2”, “crypto-js”: “^4.2.0”, “dotenv”: “^16.0.3”, “ecstatic”: “^4.1.4”, “hosted-git-info”: “^4.0.2”, “joi”: “^17.9.1”, “lodash”: “^4.17.21”, “moment”: “^2.29.4”, “selenium”: “^2.20.0”, “selenium-server”: “^3.141.59”, “selenium-standalone”: “^6.24.0”, “wdio-geckodriver-service”: “^1.0.0”, “webdriverio”: “^8.20.4”, “ws”: “^7.2.0” },
“overrides”: { “notifications-node-client”: { “jsonwebtoken”: “9.0.0” }, “@azure/identity”: { “jsonwebtoken”: “9.0.0” }, “semver” : “7.5.2” }, “devDependencies”: { “@babel/core”: “^7.23.2”, “@rpii/wdio-html-reporter”: “^7.0.0”, “@wdio/allure-reporter”: “^7.16.3”, “@wdio/cli”: “^7.14.0”, “@wdio/cucumber-framework”: “^8.20.3”, “@wdio/local-runner”: “^7.10.1”, “@wdio/selenium-standalone-service”: “^8.8.6”, “@wdio/spec-reporter”: “^7.13.2”, “allure-commandline”: “^2.13.8”, “babel-jest”: “^24.8.0”, “chromedriver”: “^118.0.1”, “cucumber-html-reporter”: “^5.5.0”, “http-server”: “^14.1.1”, “jest”: “^26.6.3”, “npm-run-all”: “^4.1.5”, “pngjs”: “^5.0.0”, “standard”: “12.0.1”, “wdio-chromedriver-service”: “^8.1.1”, “wdio-cucumberjs-json-reporter”: “^5.1.8” },
wdio.config.js
import allureReporter from ‘@wdio/allure-reporter’
import cucumberJson from ‘wdio-cucumberjs-json-reporter’
require(‘dotenv’).config({ path: .env.${process.env.ENV} })
const envRoot = (process.env.TEST_ENVIRONMENT_ROOT_URL)
const allure_config = { outputDir: ‘allure-results’, disableWebdriverStepsReporting: true, disableWebdriverScreenshotsReporting: false, useCucumberStepReporter: true, addConsoleLogs: true }
exports.config = {
runner: ‘local’,
hostname: process.env.HOST_NAME || ‘localhost’, port: 4444, path: ‘/wd/hub/’, protocol: ‘http’,
specs: [‘./features/**/*.feature’],
maxInstances: 1, capabilities: [ { maxInstances: 1, acceptInsecureCerts: true, browserName: ‘chrome’, ‘goog:chromeOptions’: { args: [ ‘–no-sandbox’, ‘–disable-gpu’, ‘–disable-dev-shm-usage’, ‘–window-size=1920,1080’ ] } } ],
logLevel: ‘debug’, //
bail: 0,
baseUrl: envRoot,
waitforTimeout: 20000,
connectionRetryTimeout: 120000,
connectionRetryCount: 1,
framework: ‘cucumber’,
reporters: [‘spec’],
runner: ‘local’,
cucumberOpts: { // <string[]> (file/dir) require files before executing features require: [‘./steps/**/*.js’], // <boolean> show full backtrace for errors backtrace: false, // <string[]> (“extension:module”) require files with the given EXTENSION after requiring MODULE (repeatable) requireModule: [], // <boolean> invoke formatters without executing steps dryRun: false, // <boolean> abort the run on first failure failFast: false, // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable) format: [‘pretty’], // <boolean> hide step definition snippets for pending steps snippets: true, // <boolean> hide source uris source: true, // <string[]> (name) specify the profile to use profile: [], // <boolean> fail if there are any undefined or pending steps strict: false, // <string> (expression) only execute the features or scenarios with tags matching the expression tagExpression: ‘’, // <number> timeout for step definitions timeout: 60000, // <boolean> Enable this config to treat undefined definitions as warnings. ignoreUndefinedDefinitions: false },
// // ===== // Hooks // ===== // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance // it and to build services around it. You can either apply a single function or an array of // methods to it. 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.
- @param {Object} config wdio configuration object
- @param {Array.<Object>} capabilities list of capabilities details / // onPrepare: function (config, capabilities) { // }, /*
- Gets executed before a worker process is spawned and can be used to initialise specific service
- for that worker as well as modify runtime environments in an async fashion.
- @param {String} cid capability id (e.g 0-0)
- @param {[type]} caps object containing capabilities for session that will be spawn in the worker
- @param {[type]} specs specs to be run in the worker process
- @param {[type]} args object that will be merged with the main configuration once worker is initialised
- @param {[type]} execArgv list of string arguments passed to the worker process / // onWorkerStart: function (cid, caps, specs, args, execArgv) { // }, /*
- Gets executed just before initialising the webdriver session and test framework. It allows you
- to manipulate configurations depending on the capability or spec.
- @param {Object} config wdio configuration object
- @param {Array.<Object>} capabilities list of capabilities details
- @param {Array.<String>} specs List of spec file paths that are to be run
- @param {String} cid worker id (e.g. 0-0) / // beforeSession: function (config, capabilities, specs, cid) { // }, /*
- 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. - @param {Array.<Object>} capabilities list of capabilities details
- @param {Array.<String>} specs List of spec file paths that are to be run
- @param {Object} browser instance of created browser/device session */ // before: async function (capabilities, specs) {
// allureReporter.addLabel(“Initial configuration”); // }, /**
- Runs before a WebdriverIO command gets executed.
- @param {String} commandName hook command name
- @param {Array} args arguments that command would receive / // beforeCommand: function (commandName, args) { // }, /*
- Cucumber Hooks
- Runs before a Cucumber Feature.
- @param {String} uri path to feature file
- @param {GherkinDocument.IFeature} feature Cucumber feature object */ beforeFeature: async function (uri, feature) { allureReporter.addStep('Starting Fetaure : ’ + feature.name)
await browser.maximizeWindow()
}, /** *
- Runs before a Cucumber Scenario.
- @param {ITestCaseHookParameter} world world object containing information on pickle and test step / beforeScenario: async function (world) { await allureReporter.addFeature(world.name) }, /*
- Runs before a Cucumber Step.
- @param {Pickle.IPickleStep} step step data
- @param {IPickle} scenario scenario pickle / // beforeStep: function (step, scenario) { // }, /*
- Runs after a Cucumber Step.
- @param {Pickle.IPickleStep} step step data
- @param {IPickle} scenario scenario pickle
- @param {Object} result results object containing scenario results
- @param {boolean} result.passed true if scenario has passed
- @param {string} result.error error stack if scenario failed
- @param {number} result.duration duration of scenario in milliseconds / afterStep: async function (step, scenario, result) { cucumberJson.attach(await browser.takeScreenshot(), ‘image/png’) } /*
- Runs before a Cucumber Scenario.
- @param {ITestCaseHookParameter} world world object containing information on pickle and test step
- @param {Object} result results object containing scenario results
- @param {boolean} result.passed true if scenario has passed
- @param {string} result.error error stack if scenario failed
- @param {number} result.duration duration of scenario in milliseconds / // afterScenario: function (world, result) { // }, /*
- Runs after a Cucumber Feature.
- @param {String} uri path to feature file
- @param {GherkinDocument.IFeature} feature Cucumber feature object */ // afterFeature: function (uri, feature) { // },
/**
- Runs after a WebdriverIO command gets executed
- @param {String} commandName hook command name
- @param {Array} args arguments that command would receive
- @param {Number} result 0 - command success, 1 - command error
- @param {Object} error error object if any / // afterCommand: function (commandName, args, result, error) { // }, /*
- Gets executed after all tests are done. You still have access to all global variables from
- the test.
- @param {Number} result 0 - test pass, 1 - test fail
- @param {Array.<Object>} capabilities list of capabilities details
- @param {Array.<String>} specs List of spec file paths that ran / // after: function (result, capabilities, specs) { // }, /*
- Gets executed right after terminating the webdriver session.
- @param {Object} config wdio configuration object
- @param {Array.<Object>} capabilities list of capabilities details
- @param {Array.<String>} specs List of spec file paths that ran / // afterSession: function (config, capabilities, specs) { // }, /*
- Gets executed after all workers got shut down and the process is about to exit. An error
- thrown in the onComplete hook will result in the test run failing.
- @param {Object} exitCode 0 - success, 1 - fail
- @param {Object} config wdio configuration object
- @param {Array.<Object>} capabilities list of capabilities details
- @param {<Object>} results object containing test results / // onComplete: function(exitCode, config, capabilities, results) { // }, /*
- Gets executed when a refresh happens.
- @param {String} oldSessionId session ID of the old session
- @param {String} newSessionId session ID of the new session */ // onReload: function(oldSessionId, newSessionId) { // } }
What is your expected behavior?
No response
How to reproduce the bug.
use the following dependencies and configuration to execute the code
Relevant log output
@wdio/local-runner: Failed launching test session: TypeError: Cannot read properties of undefined (reading 'init')
[0-4] at Runner.run (C:\Users\sramasub\OneDrive - Capgemini\Desktop\Claim_08Aug\ffc-ahwr-farmer-claim\test\acceptance\node_modules\@wdio\runner\build\index.js:83:49)
[0-4] at processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-11-01T15:04:10.911Z DEBUG @wdio/local-runner: Runner 0-4 finished with exit code 1
Code of Conduct
- I agree to follow this project’s Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 15 (7 by maintainers)
Try to re-setup WebdriverIO in your project. Make it work with a single test and then add more.