Skip to content

[🐛 Bug]: Skips creating multiremote session when that session is excluded #13875

@damencho

Description

@damencho

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.2.11

Node.js Version

v20.9.0

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

When you have for example two capabilities defined and a suite is included in specs, but the same suite is excluded for one of the capabilities via:

'wdio:exclude': [
                    'test/example.spec.ts'
                ]

Still both browsers are open even though one of them is excluded from that spec run.

What is your expected behavior?

I expect to have the browser capability participant1 to be used in this scenario and only one browser session to be created.

How to reproduce the bug.

have a file test/example.spec.ts:

describe('some example test', () => {
    console.log('the example after describe');
    it('abc', async () => {
        console.log('the example it');
    });
});

Use the following config:

import url from 'node:url'
import path from 'node:path'

const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

export const config: Omit<WebdriverIO.Config, 'capabilities'> = {
    runner: 'local',
    specs: [
        'test/example.spec.ts'
    ],

    capabilities: {
        participant1: {
            capabilities: {
                browserName: 'chrome'
            }
        },
        participant2: {
            capabilities: {
                browserName: 'chrome',
                'wdio:exclude': [
                    'test/example.spec.ts'
                ]
            }
        }
    },

    maxInstances: 1,
    logLevel: 'trace',
    outputDir: path.resolve(__dirname, 'logs'),
    framework: 'jasmine',
    jasmineOpts: {
        defaultTimeoutInterval: 60000,
    }
}

Use the package.json from jasmine-boilerplate.

When you run the example it will create two browser windows although participant2 has that test excluded.

Relevant log output

wdio-0-0-chromedriver.log

Starting ChromeDriver 130.0.6723.117 (37382504fe66965a688029d08706ddadca7ceb46-refs/branch-heads/6723@{#1765}) on port 54252
Remote connections are allowed by an allowlist (0.0.0.0).
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully on port 54252.

wdio-0-0.log:

2024-11-11T23:38:31.238Z INFO @wdio/local-runner: Run worker command: run
2024-11-11T23:38:31.243Z DEBUG @wdio/runner: init multiremote session
2024-11-11T23:38:31.306Z DEBUG @wdio/runner: init multiremote session
2024-11-11T23:38:31.307Z INFO webdriver: Initiate new session using the WebDriver protocol
2024-11-11T23:38:31.307Z INFO webdriver: Initiate new session using the WebDriver protocol
2024-11-11T23:38:31.603Z INFO webdriver: Using Chromedriver v130.0.6723.117 from cache directory /var/folders/ds/rc1dsq2s12n1yg6wp9mfr4900000gq/T
2024-11-11T23:38:31.608Z INFO webdriver: Using Chromedriver v130.0.6723.117 from cache directory /var/folders/ds/rc1dsq2s12n1yg6wp9mfr4900000gq/T
2024-11-11T23:38:32.618Z INFO @wdio/utils: Started Chromedriver v130.0.6723.117 with params --port=54251 --allowed-origins=* --allowed-ips=0.0.0.0 in 1090ms on port 54251
2024-11-11T23:38:32.648Z INFO webdriver: [POST] http://localhost:54251/session
2024-11-11T23:38:32.648Z INFO webdriver: DATA {
  capabilities: {
    alwaysMatch: {
      browserName: 'chrome',
      'goog:chromeOptions': [Object],
      webSocketUrl: true,
      unhandledPromptBehavior: 'ignore'
    },
    firstMatch: [ {} ]
  }
}
2024-11-11T23:38:32.653Z INFO @wdio/utils: Started Chromedriver v130.0.6723.117 with params --port=54252 --allowed-origins=* --allowed-ips=0.0.0.0 in 1124ms on port 54252
2024-11-11T23:38:32.653Z INFO webdriver: [POST] http://localhost:54252/session
2024-11-11T23:38:32.653Z INFO webdriver: DATA {
  capabilities: {
    alwaysMatch: {
      browserName: 'chrome',
      'wdio:exclude': [Array],
      'goog:chromeOptions': [Object],
      webSocketUrl: true,
      unhandledPromptBehavior: 'ignore'
    },
    firstMatch: [ {} ]
  }
}
2024-11-11T23:38:33.816Z INFO webdriver: Register BiDi handler for session with id 67595f98288e27a3cb7ddbffd5aaafcc
2024-11-11T23:38:33.816Z INFO webdriver: Connect to webSocketUrl ws://127.0.0.1:54252/session/67595f98288e27a3cb7ddbffd5aaafcc
2024-11-11T23:38:33.838Z INFO webdriver: Register BiDi handler for session with id 43d1923def99e1d0330c3446734db5f5
2024-11-11T23:38:33.838Z INFO webdriver: Connect to webSocketUrl ws://127.0.0.1:54251/session/43d1923def99e1d0330c3446734db5f5
2024-11-11T23:38:33.852Z INFO webdriver: Connected session to Bidi protocol
2024-11-11T23:38:33.861Z INFO webdriver: COMMAND getWindowHandle()
2024-11-11T23:38:33.861Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["log.entryAdded","browsingContext.navigationStarted"]}
2024-11-11T23:38:33.862Z INFO webdriver: BIDI COMMAND script.addPreloadScript { functionDeclaration: <PreloadScript[1267 bytes]>, contexts: undefined }
2024-11-11T23:38:33.862Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["browsingContext.navigationStarted","network.responseCompleted","network.beforeRequestSent","network.fetchError"]}
2024-11-11T23:38:33.862Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["browsingContext.userPromptOpened"]}
2024-11-11T23:38:33.862Z INFO webdriver: COMMAND getWindowHandle()
2024-11-11T23:38:33.862Z INFO webdriver: Connected to WebDriver Bidi interface at ws://127.0.0.1:54252/session/67595f98288e27a3cb7ddbffd5aaafcc
2024-11-11T23:38:33.862Z INFO webdriver: [GET] http://localhost:54252/session/67595f98288e27a3cb7ddbffd5aaafcc/window
2024-11-11T23:38:33.862Z INFO webdriver: [GET] http://localhost:54252/session/67595f98288e27a3cb7ddbffd5aaafcc/window
2024-11-11T23:38:33.863Z INFO webdriver: COMMAND getWindowHandle()
2024-11-11T23:38:33.863Z INFO webdriver: [GET] http://localhost:54252/session/67595f98288e27a3cb7ddbffd5aaafcc/window
2024-11-11T23:38:33.868Z INFO webdriver: Connected session to Bidi protocol
2024-11-11T23:38:33.869Z INFO webdriver: COMMAND getWindowHandle()
2024-11-11T23:38:33.869Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["log.entryAdded","browsingContext.navigationStarted"]}
2024-11-11T23:38:33.869Z INFO webdriver: BIDI COMMAND script.addPreloadScript { functionDeclaration: <PreloadScript[1267 bytes]>, contexts: undefined }
2024-11-11T23:38:33.869Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["browsingContext.navigationStarted","network.responseCompleted","network.beforeRequestSent","network.fetchError"]}
2024-11-11T23:38:33.870Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["browsingContext.userPromptOpened"]}
2024-11-11T23:38:33.870Z INFO webdriver: COMMAND getWindowHandle()
2024-11-11T23:38:33.870Z INFO webdriver: Connected to WebDriver Bidi interface at ws://127.0.0.1:54251/session/43d1923def99e1d0330c3446734db5f5
2024-11-11T23:38:33.870Z INFO webdriver: [GET] http://localhost:54251/session/43d1923def99e1d0330c3446734db5f5/window
2024-11-11T23:38:33.870Z INFO webdriver: [GET] http://localhost:54251/session/43d1923def99e1d0330c3446734db5f5/window
2024-11-11T23:38:33.873Z INFO webdriver: COMMAND getWindowHandle()
2024-11-11T23:38:33.874Z INFO webdriver: [GET] http://localhost:54251/session/43d1923def99e1d0330c3446734db5f5/window
2024-11-11T23:38:33.895Z INFO webdriver: RESULT E8D18EB7FECF6AB717A74C79D6147703
2024-11-11T23:38:33.896Z INFO webdriver: BIDI COMMAND script.callFunction {"functionDeclaration":"<Function[220 bytes]>","awaitPromise":true,"arguments":[{"type":"string","value":"var __defProp = Object.defineProperty;var __name = function (target, value) { return __defProp(target, 'name', { value: value, configurable: true }); };var __globalThis = (typeof globalThis === 'object' && globalThis) || (typeof window === 'object' && window);__globalThis.__name = __name;"}],"target":{"context":"E8D18EB7FECF6AB717A74C79D6147703"}}
2024-11-11T23:38:33.896Z INFO webdriver: RESULT 5E2BB28C6D0AC760C8E47A9E9C0C0BAC
2024-11-11T23:38:33.896Z INFO webdriver: BIDI COMMAND script.callFunction {"functionDeclaration":"<Function[220 bytes]>","awaitPromise":true,"arguments":[{"type":"string","value":"var __defProp = Object.defineProperty;var __name = function (target, value) { return __defProp(target, 'name', { value: value, configurable: true }); };var __globalThis = (typeof globalThis === 'object' && globalThis) || (typeof window === 'object' && window);__globalThis.__name = __name;"}],"target":{"context":"5E2BB28C6D0AC760C8E47A9E9C0C0BAC"}}
2024-11-11T23:38:33.901Z INFO webdriver: RESULT E8D18EB7FECF6AB717A74C79D6147703
2024-11-11T23:38:33.902Z INFO webdriver: BIDI COMMAND script.addPreloadScript { functionDeclaration: <PreloadScript[482 bytes]>, contexts: ["E8D18EB7FECF6AB717A74C79D6147703"] }
2024-11-11T23:38:33.909Z INFO webdriver: RESULT 5E2BB28C6D0AC760C8E47A9E9C0C0BAC
2024-11-11T23:38:33.911Z DEBUG webdriver: BIDI RESULT {"id":1,"result":{},"type":"success"}
2024-11-11T23:38:33.912Z INFO webdriver: RESULT 5E2BB28C6D0AC760C8E47A9E9C0C0BAC
2024-11-11T23:38:33.912Z INFO webdriver: BIDI COMMAND script.addPreloadScript { functionDeclaration: <PreloadScript[482 bytes]>, contexts: ["5E2BB28C6D0AC760C8E47A9E9C0C0BAC"] }
2024-11-11T23:38:33.913Z INFO webdriver: RESULT E8D18EB7FECF6AB717A74C79D6147703
2024-11-11T23:38:33.913Z DEBUG webdriver: BIDI RESULT {"id":1,"result":{},"type":"success"}
2024-11-11T23:38:33.914Z DEBUG webdriver: BIDI RESULT {"id":2,"result":{"script":"eeddc31b-7e88-4c94-99f1-d3eb78dca244"},"type":"success"}
2024-11-11T23:38:33.915Z DEBUG webdriver: BIDI RESULT {"id":2,"result":{"script":"994c063f-8693-4135-ac51-613464126207"},"type":"success"}
2024-11-11T23:38:33.915Z DEBUG webdriver: BIDI RESULT {"id":3,"result":{},"type":"success"}
2024-11-11T23:38:33.916Z DEBUG webdriver: BIDI RESULT {"id":3,"result":{},"type":"success"}
2024-11-11T23:38:33.916Z DEBUG webdriver: BIDI RESULT {"id":4,"result":{},"type":"success"}
2024-11-11T23:38:33.916Z DEBUG webdriver: BIDI RESULT {"id":4,"result":{},"type":"success"}
2024-11-11T23:38:33.917Z DEBUG webdriver: BIDI RESULT {"id":5,"result":{"realm":"-6562042341287976135.-4125209509117237242","result":{"type":"undefined"},"type":"success"},"type":"success"}
2024-11-11T23:38:33.918Z DEBUG webdriver: BIDI RESULT {"id":5,"result":{"realm":"-5916183859845247061.7368435214604586277","result":{"type":"undefined"},"type":"success"},"type":"success"}
2024-11-11T23:38:33.918Z DEBUG webdriver: BIDI RESULT {"id":6,"result":{"script":"1edb2c91-fdff-497d-b457-16318f613f5f"},"type":"success"}
2024-11-11T23:38:33.918Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["script.message"]}
2024-11-11T23:38:33.918Z DEBUG webdriver: BIDI RESULT {"id":6,"result":{"script":"288c71ad-beb2-4bf2-acfd-f1d3bdbb745e"},"type":"success"}
2024-11-11T23:38:33.918Z INFO webdriver: BIDI COMMAND session.subscribe {"events":["script.message"]}
2024-11-11T23:38:33.919Z DEBUG webdriver: BIDI RESULT {"id":7,"result":{},"type":"success"}
2024-11-11T23:38:33.920Z INFO webdriverio:PolyfillManager: polyfill script added
2024-11-11T23:38:33.920Z DEBUG webdriver: BIDI RESULT {"id":7,"result":{},"type":"success"}
2024-11-11T23:38:33.920Z INFO webdriverio:PolyfillManager: polyfill script added
2024-11-11T23:38:33.925Z DEBUG @wdio/utils:shim: Finished to run "beforeTest" hook in 0ms
2024-11-11T23:38:33.926Z DEBUG @wdio/utils:shim: Finished to run "after" hook in 0ms
2024-11-11T23:38:33.926Z INFO webdriver: COMMAND deleteSession()
2024-11-11T23:38:33.926Z INFO webdriver: [DELETE] http://localhost:54252/session/67595f98288e27a3cb7ddbffd5aaafcc
2024-11-11T23:38:33.927Z INFO webdriver: COMMAND deleteSession()
2024-11-11T23:38:33.927Z INFO webdriver: [DELETE] http://localhost:54251/session/43d1923def99e1d0330c3446734db5f5
2024-11-11T23:38:33.983Z INFO webdriver: RESULT null
2024-11-11T23:38:33.983Z INFO webdriver: Kill driver process with PID 54473
2024-11-11T23:38:33.983Z INFO webdriver: RESULT null
2024-11-11T23:38:33.983Z INFO webdriver: Kill driver process with PID 54474

wdio.log:

2024-11-11T23:38:30.741Z INFO @wdio/cli:launcher: Run onPrepare hook
2024-11-11T23:38:30.742Z INFO @wdio/utils: Setting up browser driver for: chrome@stable
2024-11-11T23:38:30.742Z INFO @wdio/utils: Setting up browser binaries for: chrome@stable
2024-11-11T23:38:30.774Z INFO webdriver: Using Chromedriver v130.0.6723.117 from cache directory /var/folders/ds/rc1dsq2s12n1yg6wp9mfr4900000gq/T
2024-11-11T23:38:30.805Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2024-11-11T23:38:30.806Z INFO @wdio/local-runner: Start worker 0-0 with arg: run wdio.conf.ts
2024-11-11T23:38:30.807Z DEBUG @wdio/local-runner: Send command run to worker with cid "0-0"
2024-11-11T23:38:34.093Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 0
2024-11-11T23:38:34.094Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2024-11-11T23:38:34.094Z INFO @wdio/cli:launcher: Run onComplete hook
2024-11-11T23:38:34.116Z INFO @wdio/local-runner: Shutting down spawned worker
2024-11-11T23:38:34.368Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancementhelp 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