Cannot Run Appium Webdriver IO Test

Hi Guys,

I’m having a massive headache trying to run my first webdriverIO Appium test.
Appium is set up OK
The WDIO file seems ok
It seems it is initialising Appium programatically (so I don’t need to turn appium on)

When I Try to run a sample test, it won’t run the test.

What is wrong and how can I fix it?

Let me show you the log files:

Execution of 1 workers started at 2022-02-05T16:37:33.955Z

2022-02-05T16:37:33.963Z DEBUG @wdio/utils:initialiseServices: initialise service "appium" as NPM package
2022-02-05T16:37:34.152Z INFO @wdio/cli:launcher: Run onPrepare hook
2022-02-05T16:37:34.155Z DEBUG @wdio/appium-service: Will spawn Appium process: appium --base-path / --session-override --debug-log-spacing --no-reset --automation-name XCUITest --platform-name iOS --platform-version 15.2 --device-name 'iPhone 13 Simulator' --udid E948D1B3-15E8-4782-824F-0A3BBAA45C7E --app com.apple.Preferences
2022-02-05T16:37:38.491Z DEBUG @wdio/appium-service: Appium started with ID: 83676
2022-02-05T16:37:38.492Z DEBUG @wdio/cli:utils: Finished to run "onPrepare" hook in 4339ms
2022-02-05T16:37:38.495Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2022-02-05T16:37:38.495Z DEBUG @wdio/cli:utils: Finished to run "onWorkerStart" hook in 0ms
2022-02-05T16:37:38.498Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,./config/wdio.conf.ts
[0-0] 2022-02-05T16:37:41.532Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2022-02-05T16:37:43.058Z DEBUG @wdio/config:utils: Found 'ts-node' package, auto-compiling TypeScript files
[0-0] 2022-02-05T16:37:43.624Z DEBUG @wdio/local-runner:utils: init remote session
[0-0] 2022-02-05T16:37:43.654Z DEBUG @wdio/utils:initialiseServices: initialise service "appium" as NPM package
[0-0] RUNNING in undefined - /src/featureFiles/sampleTest.feature
[0-0] 2022-02-05T16:37:46.089Z DEBUG @wdio/local-runner:utils: init remote session
[0-0] 2022-02-05T16:37:46.092Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2022-02-05T16:37:46.505Z INFO webdriver: [POST] http://localhost:4723/session
[0-0] 2022-02-05T16:37:46.506Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {}
[0-0] }
[0-0] 2022-02-05T16:39:46.878Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
[0-0] 2022-02-05T16:39:46.883Z INFO webdriver: Retrying 1/3
[0-0] 2022-02-05T16:39:46.902Z INFO webdriver: [POST] http://localhost:4723/session
[0-0] 2022-02-05T16:39:46.920Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {}
[0-0] }
[0-0] 2022-02-05T16:41:47.015Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
[0-0] 2022-02-05T16:41:47.023Z INFO webdriver: Retrying 2/3
[0-0] 2022-02-05T16:41:47.023Z INFO webdriver: [POST] http://localhost:4723/session
[0-0] 2022-02-05T16:41:47.024Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {}
[0-0] }
[0-0] 2022-02-05T16:43:47.081Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
[0-0] 2022-02-05T16:43:47.086Z INFO webdriver: Retrying 3/3
[0-0] 2022-02-05T16:43:47.086Z INFO webdriver: [POST] http://localhost:4723/session
[0-0] 2022-02-05T16:43:47.086Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {}
[0-0] }
[0-0] 2022-02-05T16:45:47.144Z ERROR webdriver: Request failed with status undefined due to TimeoutError: Timeout awaiting 'request' for 120000ms when running "http://localhost:4723/session" with method "POST" and args "{"capabilities":{"alwaysMatch":{},"firstMatch":[{}]},"desiredCapabilities":{}}"
[0-0] 2022-02-05T16:45:47.152Z ERROR webdriver: TimeoutError: Timeout awaiting 'request' for 120000ms when running "http://localhost:4723/session" with method "POST" and args "{"capabilities":{"alwaysMatch":{},"firstMatch":[{}]},"desiredCapabilities":{}}"
[0-0]     at getTimeoutError (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriver/build/utils.js:322:24)
[0-0]     at NodeJSRequest._request (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriver/build/request/index.js:147:59)
[0-0]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[0-0]     at async startWebDriverSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriver/build/utils.js:67:20)
[0-0]     at async Function.newSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriver/build/index.js:42:45)
[0-0]     at async remote (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriverio/build/index.js:73:22)
[0-0]     at async Runner._startSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/build/index.js:223:56)
[0-0]     at async Runner._initSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/build/index.js:176:25)
[0-0]     at async Runner.run (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/build/index.js:88:19)
[0-0] 2022-02-05T16:45:47.475Z ERROR @wdio/runner: Error: Failed to create session.
[0-0] Timeout awaiting 'request' for 120000ms when running "http://localhost:4723/session" with method "POST" and args "{"capabilities":{"alwaysMatch":{},"firstMatch":[{}]},"desiredCapabilities":{}}"
[0-0]     at startWebDriverSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriver/build/utils.js:72:15)
[0-0]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[0-0]     at async Function.newSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriver/build/index.js:42:45)
[0-0]     at async remote (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/node_modules/webdriverio/build/index.js:73:22)
[0-0]     at async Runner._startSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/build/index.js:223:56)
[0-0]     at async Runner._initSession (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/build/index.js:176:25)
[0-0]     at async Runner.run (/Users/jacquelinegeorge/Documents/WebdriverIO-V6-appium-cucumber-boilerplate-master/node_modules/@wdio/runner/build/index.js:88:19)
2022-02-05T16:45:47.748Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in undefined - /src/featureFiles/sampleTest.feature
2022-02-05T16:45:47.761Z INFO @wdio/cli:launcher: Run onComplete hook
2022-02-05T16:45:47.764Z DEBUG @wdio/appium-service: Appium (pid: 83676) killed
2022-02-05T16:45:47.765Z DEBUG @wdio/cli:utils: Finished to run "onComplete" hook in 3ms

Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:08:13 

2022-02-05T16:45:47.770Z INFO @wdio/local-runner: Shutting down spawned worker
2022-02-05T16:45:48.027Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2022-02-05T16:45:48.031Z INFO @wdio/local-runner: shutting down

TS. Config file
{
“compilerOptions”: {
“outDir”: “./.tsbuild/”,
“sourceMap”: false,
“target”: “es2019”,
“module”: “commonjs”,
“removeComments”: true,
“noImplicitAny”: true,
“strictPropertyInitialization”: true,
“strictNullChecks”: true,
“types”: [
“node”,
“webdriverio/async”,
@wdio/mocha-framework”,
@wdio/sauce-service”,
@wdio/appium-service” ]
},
“include”: [
“./src/**/*.ts”
]
}

here is the wdioconfig.js file

import { join } from 'path';
export const config : WebdriverIO.Config = {


    //
    // ====================
    // Runner Configuration
    // ====================
    //
    // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
    // on a remote machine).
    runner: 'local',
    //sync: true,
    //
    // ==================
    // 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: [
        './src/featureFiles/sampleTest.feature'
    ],
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    // ============
    // Capabilities
    // ============
    // Define your capabilities here. WebdriverIO can run multiple capabilities 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 options in
    // order to group specific specs to a specific capability.
    //
    // First, you can define how many instances should be started at the same time. Let's
    // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
    // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
    // files and you set maxInstances to 10, all spec files will get tested at the same time
    // and 30 processes will get spawned. The property handles how many capabilities
    // from the same test should run tests.
    //
    //
    // 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: [{
    // capabilities are added in the individual config files for browser and native apps
    
    }],
    //
    // ===================
    // Test Configurations
    // ===================
    // Define all options that are relevant for the WebdriverIO instance here
    //
    // Level of logging verbosity: trace | debug | info | warn | error | silent
    logLevel: 'debug',
    //
    // Set specific log levels per logger
    // loggers:
    // - webdriver, webdriverio
    // - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
    // - @wdio/mocha-framework, @wdio/jasmine-framework
    // - @wdio/local-runner, @wdio/lambda-runner
    // - @wdio/sumologic-reporter
    // - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils
    // Level of logging verbosity: trace | debug | info | warn | error | silent
    logLevels: {
        webdriver: 'debug',
        '@wdio/applitools-service': 'debug'
    },
    //
    // If you only want to run your tests until a specific amount of tests have failed use
    // bail (default is 0 - don't bail, run all tests).
    bail: 0,
    // Default timeout for all waitFor* commands.
    waitforTimeout: 10000,
    //
    // Default timeout in milliseconds for request
    // if browser driver or grid doesn't send response
    connectionRetryTimeout: 120000,
    //
    // Default request retries count
    connectionRetryCount: 3,
    //
    // Test runner services
    // Services take over a specific job you don't want to take care of. They enhance
    // your test setup with almost no effort. Unlike plugins, they don't add new
    // commands. Instead, they hook themselves up into the test process.
    services: [
        //  "chromedriver",
        //  "sauce",
          [
            "appium",
            {
              command: "appium",
              args: {
                sessionOverride: true,
                debugLogSpacing: true,
                noReset: true,
                fullReset: false,
                automationName: "XCUITest",
                platformName: "iOS",
                platformVersion: "15.2",
                deviceName: "iPhone 13 Simulator",
                udid: "E948D1B3-15E8-4782-824F-0A3BBAA45C7E",
                app: "com.apple.Preferences",
              },
            },
          ],
        ],
    port: 4723,
    path: '/wd/hub',
    // Framework you want to run your specs with.
    // The following are supported: Mocha, Jasmine, and Cucumber
    // see also: https://webdriver.io/docs/frameworks.html
    //
    // Make sure you have the wdio adapter package for the specific framework installed
    // before running any tests.
    framework: 'cucumber',
    cucumberOpts: {
        backtrace: false,
        requireModule: [],
        failAmbiguousDefinitions: false,
        failFast: false,
        ignoreUndefinedDefinitions: false,
        name: [],
        profile: [],
        require: [
            './src/stepDefinitions/steps.ts'
           
        ],
        snippetSyntax: undefined,
        snippets: true,
        source: true,
        strict: false,
        tagsInTitle: false,
        timeout: 50000,
        retry: 0
    },
    //
    // The number of times to retry the entire specfile when it fails as a whole
    // specFileRetries: 1,
    //
    // Whether or not retried specfiles should be retried immediately or deferred to the end of the queue
    // specFileRetriesDeferred: false,
    //
    // Test reporter for stdout.
    // The only one supported by default is 'dot'
    // see also: https://webdriver.io/docs/dot-reporter.html
    reporters: ["spec", ["allure", { outputDir: "allure-results" }]],
    // =====
    // 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
     */
    // beforeSession: function (config, capabilities, specs) {
    // },
    /**
     * 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
     */
    // before: function (capabilities, specs) {
    // },
    /**
     * 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) {
    // },
    /**
     * Hook that gets executed before the suite starts
     * @param {Object} suite suite details
     */
    // beforeSuite: function (suite) {
    // },
    /**
     * Function to be executed before a test (in Mocha/Jasmine) starts.
     */
    // beforeTest: function (test, context) {
    // },
    /**
     * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
     * beforeEach in Mocha)
     */
    // beforeHook: function (test, context) {
    // },
    /**
     * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
     * afterEach in Mocha)
     */
    // afterHook: function (test, context, { error, result, duration, passed, retries }) {
    // },
    /**
     * Function to be executed after a test (in Mocha/Jasmine).
     */
    // afterTest: function(test, context, { error, result, duration, passed, retries }) {
    // },


    /**
     * Hook that gets executed after the suite has ended
     * @param {Object} suite suite details
     */
    // afterSuite: function (suite) {
    // },
    /**
     * 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) {
        generate({
            jsonDir: './reports/json',
            reportPath: './reports/html',
            openReportInBrowser: true
        }); */
    //},
    /**
     * 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) {
    //}
}
import { join } from 'path';
export const config : WebdriverIO.Config = {


    //
    // ====================
    // Runner Configuration
    // ====================
    //
    // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
    // on a remote machine).
    runner: 'local',
    //sync: true,
    //
    // ==================
    // 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: [
        './src/featureFiles/sampleTest.feature'
    ],
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    // ============
    // Capabilities
    // ============
    // Define your capabilities here. WebdriverIO can run multiple capabilities 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 options in
    // order to group specific specs to a specific capability.
    //
    // First, you can define how many instances should be started at the same time. Let's
    // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
    // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
    // files and you set maxInstances to 10, all spec files will get tested at the same time
    // and 30 processes will get spawned. The property handles how many capabilities
    // from the same test should run tests.
    //
    //
    // 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: [{
    // capabilities are added in the individual config files for browser and native apps
    
    }],
    //
    // ===================
    // Test Configurations
    // ===================
    // Define all options that are relevant for the WebdriverIO instance here
    //
    // Level of logging verbosity: trace | debug | info | warn | error | silent
    logLevel: 'debug',
    //
    // Set specific log levels per logger
    // loggers:
    // - webdriver, webdriverio
    // - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
    // - @wdio/mocha-framework, @wdio/jasmine-framework
    // - @wdio/local-runner, @wdio/lambda-runner
    // - @wdio/sumologic-reporter
    // - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils
    // Level of logging verbosity: trace | debug | info | warn | error | silent
    logLevels: {
        webdriver: 'debug',
        '@wdio/applitools-service': 'debug'
    },
    //
    // If you only want to run your tests until a specific amount of tests have failed use
    // bail (default is 0 - don't bail, run all tests).
    bail: 0,
    // Default timeout for all waitFor* commands.
    waitforTimeout: 10000,
    //
    // Default timeout in milliseconds for request
    // if browser driver or grid doesn't send response
    connectionRetryTimeout: 120000,
    //
    // Default request retries count
    connectionRetryCount: 3,
    //
    // Test runner services
    // Services take over a specific job you don't want to take care of. They enhance
    // your test setup with almost no effort. Unlike plugins, they don't add new
    // commands. Instead, they hook themselves up into the test process.
    services: [
        //  "chromedriver",
        //  "sauce",
          [
            "appium",
            {
              command: "appium",
              args: {
                sessionOverride: true,
                debugLogSpacing: true,
                noReset: true,
                fullReset: false,
                automationName: "XCUITest",
                platformName: "iOS",
                platformVersion: "15.2",
                deviceName: "iPhone 13 Simulator",
                udid: "E948D1B3-15E8-4782-824F-0A3BBAA45C7E",
                app: "com.apple.Preferences",
              },
            },
          ],
        ],
    port: 4723,
    path: '/wd/hub',
    // Framework you want to run your specs with.
    // The following are supported: Mocha, Jasmine, and Cucumber
    // see also: https://webdriver.io/docs/frameworks.html
    //
    // Make sure you have the wdio adapter package for the specific framework installed
    // before running any tests.
    framework: 'cucumber',
    cucumberOpts: {
        backtrace: false,
        requireModule: [],
        failAmbiguousDefinitions: false,
        failFast: false,
        ignoreUndefinedDefinitions: false,
        name: [],
        profile: [],
        require: [
            './src/stepDefinitions/steps.ts'
           
        ],
        snippetSyntax: undefined,
        snippets: true,
        source: true,
        strict: false,
        tagsInTitle: false,
        timeout: 50000,
        retry: 0
    },
    //
    // The number of times to retry the entire specfile when it fails as a whole
    // specFileRetries: 1,
    //
    // Whether or not retried specfiles should be retried immediately or deferred to the end of the queue
    // specFileRetriesDeferred: false,
    //
    // Test reporter for stdout.
    // The only one supported by default is 'dot'
    // see also: https://webdriver.io/docs/dot-reporter.html
    reporters: ["spec", ["allure", { outputDir: "allure-results" }]],
    // =====
    // 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
     */
    // beforeSession: function (config, capabilities, specs) {
    // },
    /**
     * 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
     */
    // before: function (capabilities, specs) {
    // },
    /**
     * 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) {
    // },
    /**
     * Hook that gets executed before the suite starts
     * @param {Object} suite suite details
     */
    // beforeSuite: function (suite) {
    // },
    /**
     * Function to be executed before a test (in Mocha/Jasmine) starts.
     */
    // beforeTest: function (test, context) {
    // },
    /**
     * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
     * beforeEach in Mocha)
     */
    // beforeHook: function (test, context) {
    // },
    /**
     * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
     * afterEach in Mocha)
     */
    // afterHook: function (test, context, { error, result, duration, passed, retries }) {
    // },
    /**
     * Function to be executed after a test (in Mocha/Jasmine).
     */
    // afterTest: function(test, context, { error, result, duration, passed, retries }) {
    // },


    /**
     * Hook that gets executed after the suite has ended
     * @param {Object} suite suite details
     */
    // afterSuite: function (suite) {
    // },
    /**
     * 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) {
        generate({
            jsonDir: './reports/json',
            reportPath: './reports/html',
            openReportInBrowser: true
        }); */
    //},
    /**
     * 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) {
    //}
}

Have you tried checking with appium-doctor? It would be nice to see the project or wdio.conf.js

Thank you. I I will upload the wdio.confi.js file now

Just posted widio file. I would appreciate your feedback.

Here is a JavaScript tutorial, I was especially interested in the differences between his wdio.conf.js. He puts the capabilities in a different place. Hopefully this will help:

https://testautomationu.applitools.com/appium-javascript-tutorial/

1 Like

Any update on this issue? I am facing the same issue when run the script

Execution of 1 workers started at 2024-02-05T12:16:45.007Z

2024-02-05T12:16:45.041Z DEBUG @wdio/utils:initialiseServices: initialise service “appium” as NPM package
2024-02-05T12:16:45.075Z INFO @wdio/cli:launcher: Run onPrepare hook
2024-02-05T12:16:45.076Z DEBUG @wdio/appium-service: Will spawn Appium process: appium --base-path /wd/hub --base-path / --relaxed-security
Error: spawn appium --base-path /wd/hub ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: ‘ENOENT’,
syscall: ‘spawn appium --base-path /wd/hub’,
path: ‘appium --base-path /wd/hub’,
spawnargs: [ ‘–base-path’, ‘/’, ‘–relaxed-security’ ]
}