Skip to content

[🐛 Bug]: AddCommand -> Command doesn't exist for all browser #13836

@P-Courteille

Description

@P-Courteille

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.0.8

Node.js Version

22.9.0

Mode

WDIO Testrunner

Which capabilities are you using?

export const mobileWebCapabilities = [
    {
        chromeBrowser: {
            hostname: '127.0.0.1',
            "port": 9515,
            "path": "/",
            capabilities: {
                browserName: 'chrome',
                'goog:chromeOptions': {
                    args: ['--start-maximized']
                },
                'webdriver:options': {
                    hostname: '127.0.0.1',
                    port: 41325,
                    path: '/'
                }
            }
        },
        androidDevice: {
            hostname: '127.0.0.1',
            port: 4723,
            path: '/wd/hub',
            capabilities: {
                //Device 1
                ...commonMobileCapabilities,
                "appium:systemPort": 8200,
            }
        }
    }
]

What happened?

If I use addCommand with multiple browser capabilities or at least one named browser, the addCommand is not applied to all browser.

With :

before(() => {
    browser.addCommand('test', async function () {
        console.log('test')
    })
})

Current behavior :

  • browser.test() -> Working
  • chromeBrowser.test() -> is not a function
  • androidDevice.test() -> is not a function

What is your expected behavior?

The command should be available for all browser so :

  • browser.test() -> Working
  • chromeBrowser.test() -> Working
  • androidDevice.test() -> Working

How to reproduce the bug.

  1. Use a capabilities with at least one named browser
  2. AddCommand on "browser" (not on the name of the browser from step 1)
  3. Use the new command chain to browser name from step 1

Issue similar to this old fixed issue ?

Relevant log output

androidDevice.test() is not a function

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions