Skip to content

[🐛 Bug]: Bidi - deserialization issue with array reference #13972

@NIBOSAP

Description

@NIBOSAP

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.4.1

Node.js Version

18

Mode

WDIO Testrunner

Which capabilities are you using?

{
   browserName: 'chrome'
   browserVersion: 'latest'
}

What happened?

with webdriverBidi, when using browser.execute, I have an issue when the browser returns a duplicated array:
for e.g., with :

await browser.execute(() => {
            const toto = [];
            const result= [
                {
                    "id": "__button1",
                    "properties": toto
                },
                {
                    "id": "__button2",
                    "properties": toto
                }
            ]
            return result;
        })

I get:

[0-0] TypeError in "test webdriverio bidi.test with array reference"
TypeError: Cannot read properties of undefined (reading 'map')
    at Array.map (<anonymous>)
    at Array.map (<anonymous>)

This is because browser.execute returns the two arrays which have the same internalId; the first one has the value, the second one doesn't:

image

So, in the deserializeValue() function, we try to perform a .map on an undefined value.

In W3C InternalId, it says that:

In case of duplicated objects in the same script.RemoteValue, the value is provided only for one of the remote values, while the unique-per-ECMAScript-object internalId is provided for all the duplicated objects for a given serialization.

What is your expected behavior?

No error

How to reproduce the bug.

run:

const result = await browser.execute(() => {
            const toto = [];
            const result= [
                {
                    "id": "__button1",
                    "properties": toto
                },
                {
                    "id": "__button2",
                    "properties": toto
                }
            ]
            return result;
        })

here a repo: https://github.com/NIBOSAP/webdriverio-bidi/tree/main

Relevant log output

Execution of 1 workers started at 2024-12-12T18:34:04.452Z

2024-12-12T18:34:04.457Z INFO @wdio/cli:launcher: Run onPrepare hook
2024-12-12T18:34:04.457Z INFO @wdio/utils: Setting up browser driver for: chrome@stable
2024-12-12T18:34:04.458Z INFO @wdio/utils: Setting up browser binaries for: chrome@stable
2024-12-12T18:34:04.572Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2024-12-12T18:34:04.572Z INFO @wdio/local-runner: Start worker 0-0 with arg: ./wdio.default.conf.js
[0-0] 2024-12-12T18:34:04.911Z INFO @wdio/local-runner: Run worker command: run
[0-0] RUNNING in chrome - file:///test.spec.js
[0-0] 2024-12-12T18:34:05.072Z INFO chromedriver: Starting ChromeDriver 131.0.6778.140 
[0-0] 2024-12-12T18:34:05.072Z INFO chromedriver: Remote connections are allowed by an allowlist (0.0.0.0).
[0-0] 2024-12-12T18:34:05.072Z INFO chromedriver: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[0-0] 2024-12-12T18:34:05.073Z INFO chromedriver: ChromeDriver was started successfully on port 52995.
[0-0] 2024-12-12T18:34:06.074Z INFO @wdio/utils: Started Chromedriver v131.0.6778.140 with params --port=52995 --allowed-origins=* --allowed-ips=0.0.0.0 in 1049ms on port 52995
[0-0] 2024-12-12T18:34:06.881Z INFO webdriverio:PolyfillManager: polyfill script added
[0-0] TypeError in "test webdriverio bidi.test with array reference"
TypeError: Cannot read properties of undefined (reading 'map')
    at Array.map (<anonymous>)
    at Array.map (<anonymous>)
[0-0] FAILED in chrome - file:///test.spec.js
2024-12-12T18:34:08.578Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2024-12-12T18:34:08.578Z INFO @wdio/cli:launcher: Run onComplete hook

 "spec" Reporter:
------------------------------------------------------------------
[chrome 131.0.6778.140 mac #0-0] Running: chrome (v131.0.6778.140)
[chrome 131.0.6778.140 mac #0-0] Session ID: f5386dfb1f57276ca015ce4df0434a87
[chrome 131.0.6778.140 mac #0-0]
[chrome 131.0.6778.140 mac #0-0] » /test.spec.js
[chrome 131.0.6778.140 mac #0-0] test webdriverio bidi
[chrome 131.0.6778.140 mac #0-0]     test with array reference
[chrome 131.0.6778.140 mac #0-0]
[chrome 131.0.6778.140 mac #0-0] 1 failing (1.5s)
[chrome 131.0.6778.140 mac #0-0]
[chrome 131.0.6778.140 mac #0-0] 1) test webdriverio bidi test with array reference
[chrome 131.0.6778.140 mac #0-0] Cannot read properties of undefined (reading 'map')
[chrome 131.0.6778.140 mac #0-0] TypeError: Cannot read properties of undefined (reading 'map')
[chrome 131.0.6778.140 mac #0-0]     at Array.map (<anonymous>)
[chrome 131.0.6778.140 mac #0-0]     at Array.map (<anonymous>)


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

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

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions