webdriverio: [🐛 Bug]: Facing issue while executing cucumber based test cases on Appium server

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.16.4

Node.js Version

v18.16.0

Mode

WDIO Testrunner

Which capabilities are you using?

[ {
        "appium:platformName": "Android",
        "appium:automationName": "UiAutomator2",
        "appium:deviceName": "Android",
        "appium:newCommandTimeout": 3600,
        "appium:connectHardwareKeyboard": true,
        "appium:chromedriverExecutableDir": join(cwd(), "bin"),
        "appium:chromedriverUseSystemExecutable": false,
        "appium:noReset": false
    }]

What happened?

Executing test cases written in the Cucumber framework in mobile gives us this message: `You’re calling functions (e.g. “Given”) on an instance of Cucumber that isn’t running.

Connecting with Appium - ✅ Installing given APK file in mobile - ✅ onPrepare hook is passing - ✅

Test Runner stops its execution when it starts executing the step file.

What is your expected behavior?

Execution of Test cases written in gherkin files in a mobile application (through Appium).

How to reproduce the bug.

Create the following files.

Feature File:

Feature: Role-Based Access Functionality in the X Module
Scenario: If the Logged in users is an Admin
Given I login as "xyzi@ls.in"

Step definition file

import { Given } from "@wdio/cucumber-framework";

Given("I login as {string}", async () => {
    console.log("worked")
})

install appium

npm install appium So we would be using Appium v2.1.3

either run the Appium manually npx appium -p 4723 or use appium-service

now run this command npm run wdio which is in short for wdio run ./wdio.conf.js

Relevant log output

[0-0] 2023-09-07T10:06:11.383Z ERROR @wdio/runner: Error: 
[0-0]           You're calling functions (e.g. "Given") on an instance of Cucumber that isn't running.
[0-0]           This means you have an invalid installation, mostly likely due to:
[0-0]           - Cucumber being installed globally
[0-0]           - A project structure where your support code is depending on a different instance of Cucumber
[0-0]           Either way, you'll need to address this in order for Cucumber to work.
[0-0]           See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations
[0-0]
[0-0]     at checkInstall (.\@cucumber\cucumber\src\support_code_library_builder\index.ts:127:15)
[0-0]     at .\node_modules\@cucumber\cucumber\src\support_code_library_builder\index.ts:145:11
[0-0]     at file:///C:/Users/tangellapalli.s/Documents/appium-webdriverio/ace-mobile-automation/step-definitions/login.steps.js:3:1
[0-0]  Error: 
          You're calling functions (e.g. "Given") on an instance of Cucumber that isn't running.
          This means you have an invalid installation, mostly likely due to:
          - Cucumber being installed globally
          - A project structure where your support code is depending on a different instance of Cucumber      
          Either way, you'll need to address this in order for Cucumber to work.
          See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations 

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 10 months ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

Thanks for confirming!

@tamil777selvan I found the library causing this duplicate dependency issue, It’s in the global package: wdio-cucumber-framework I might have installed it accidentally.

Uninstalling it resolved this issue, hence closing this issue. Thank you

Hi @RahulARanger, Even with the code you’ve provided, I was able to execute it without any issues. Could you please verify whether you have a global installation of cucumber?

Screenshot 2023-09-08 at 7 03 13 AM

@tamil777selvan is there any way I could search for the alternate cucumber package that’s causing this issue?

Please try to gather a list of all the packages inside your project repository and see if any other version of cucumber is installed. Run the following commands:

For your project:

npm list --depth=1

For a global check:

npm list -g --depth=1

It’s working as expected in web.

@RahulARanger To confirm, I attempted to execute in wdio application using version 8.16.4, but I was unable to replicate this error. Could you please provide a sample of the code where you are encountering this issue?

Dependency version: Screenshot 2023-09-07 at 9 12 31 PM

Execution: Screenshot 2023-09-07 at 9 11 26 PM