Skip to content

fix: Fix incorrect typings and commands inconsistency#15003

Merged
christian-bromann merged 13 commits intowebdriverio:mainfrom
dprevost-LMI:fix-incorrect-typings-and-commands-inconsistency
Feb 1, 2026
Merged

fix: Fix incorrect typings and commands inconsistency#15003
christian-bromann merged 13 commits intowebdriverio:mainfrom
dprevost-LMI:fix-incorrect-typings-and-commands-inconsistency

Conversation

@dprevost-LMI
Copy link
Contributor

@dprevost-LMI dprevost-LMI commented Jan 11, 2026

Proposed changes

Fix a few typing inconsistencies and some other issues in the commands.

  • typing of getLocation and getSize needs to be a | and not a &
  • screenshot param scroll was erroring after some runtime test
  • closeWindow effectively returns a list of strings tested at runtime (can't test for now, see issue)
  • getElementAttribute returns null as already documented in the getAttribute commands
  • getElementShadowRoot & getActiveElement returns object and not string
  • getElementProperty can return any type, tested at runtime
  • print param pageRanges with object was erroring at runtime, definition says an array of string & number
  • sensor param is type at runtime test confirmed it, and the doc mentions connected
  • maxSamplingFrequency & minSamplingFrequency are for createMockSensor and not updateMockSensor + missing 'reading' param

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported

Further comments

Started after discovering a typing issue on getSize and a null missing type for getElementAttribute when playing with those in expect-wdio. Then it extended to the other inconsistencies

  • Error when using takeElementScreenshot + scroll = true
[chrome 144.0.7559.97 mac #0-0] WebDriverError: Request with GET/HEAD method cannot have body. when running "element/f.43134688C6EAF50F4D279F9C66B21CEF.d.B093AF5426A35B8A9BF8CBEA64564F87.e.3/screenshot" with method "GET"
  • Error when using print param pageRanges (fixed when overriding with (string | number)[] in node_module)
    With ['1']
[MultiremoteBrowser on chrome and firefox #0-0] Malformed type for "pageRanges" parameter of command printPage
Expected: object[]
Actual: (string)[]

For more info see https://w3c.github.io/webdriver/#print-page
  • For getElementShadowRoot the below shows it is an object and not a string
            // Get the shadow root using getElementShadowRoot
            const shadowRoot = await browser.getElementShadowRoot(await hostElement.elementId)
            console.log('Shadow root value:', shadowRoot)            
            console.log('Shadow root type:', typeof shadowRoot)
[0-0] Shadow root value: {
[0-0]   'shadow-6066-11e4-a52e-4f735466cecf': 'f.486363CDAF266AC5DEABA9E96B508379.d.31BDD81AF56F8AF0C52C7DE9D042147D.e.3'
[0-0] }
[0-0] Shadow root type: object

Similarly for getActiveElement

[0-0] Active element value: {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': 'f.391A28BC451DA04C2139F8AACC838908.d.6424A6DFB9C170F4AFAA50419BFEF417.e.3'
[0-0] }
[0-0] Active element type: object
  • For create sensor
    Using the command as previously defined throws
            await browser.createMockSensor(
                'ambient-light',  // mockSensorType
                60,               // maxSamplingFrequency (Hz)
                10                // minSamplingFrequency (Hz)
            )

throws

chrome 144.0.7559.97 mac #0-0] WebDriverError: invalid argument: 'type' must be a string
  (Session info: chrome=144.0.7559.97) when running "sensor" with method "POST"
  • For update sensor
            // This makes a POST request to /session/:sessionId/sensor/:type
            await browser.updateMockSensor(
                'ambient-light',  // type
                'ambient-light',  // mockSensorType
                50,               // maxSamplingFrequency
                5,                // minSamplingFrequency
            )

it throws

[chrome 144.0.7559.97 mac #0-0] WebDriverError: invalid argument: Missing 'reading' field
  (Session info: chrome=144.0.7559.97) when running "sensor/ambient-light" with method "POST"

For more info see https://w3c.github.io/sensors/#update-mock-sensor-reading-command

Reviewers: @webdriverio/project-committers

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 11, 2026

Open in StackBlitz

create-wdio

npm i https://pkg.pr.new/webdriverio/webdriverio/create-wdio@15003

eslint-plugin-wdio

npm i https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@15003

@wdio/allure-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@15003

@wdio/appium-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@15003

@wdio/browser-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@15003

@wdio/browserstack-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@15003

@wdio/cli

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@15003

@wdio/concise-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@15003

@wdio/config

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@15003

@wdio/cucumber-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@15003

@wdio/dot-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@15003

@wdio/firefox-profile-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@15003

@wdio/globals

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@15003

@wdio/jasmine-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@15003

@wdio/json-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@15003

@wdio/junit-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@15003

@wdio/lighthouse-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@15003

@wdio/local-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@15003

@wdio/logger

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@15003

@wdio/mocha-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@15003

@wdio/protocols

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@15003

@wdio/repl

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@15003

@wdio/reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@15003

@wdio/runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@15003

@wdio/sauce-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@15003

@wdio/shared-store-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@15003

@wdio/smoke-test-cjs-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@15003

@wdio/smoke-test-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@15003

@wdio/smoke-test-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@15003

@wdio/spec-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@15003

@wdio/static-server-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@15003

@wdio/sumologic-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@15003

@wdio/testingbot-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@15003

@wdio/types

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@15003

@wdio/utils

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@15003

@wdio/webdriver-mock-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@15003

@wdio/xvfb

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/xvfb@15003

webdriver

npm i https://pkg.pr.new/webdriverio/webdriverio/webdriver@15003

webdriverio

npm i https://pkg.pr.new/webdriverio/webdriverio@15003

commit: 3feae32

- For page range, specs says `string[]` but chrome error message also mentioned supporting numbers
- changes for `object` was validated at runtime
- getElementProperty effectively return different type at runtime
- the parameter for screenshot was tried and fails
@dprevost-LMI dprevost-LMI force-pushed the fix-incorrect-typings-and-commands-inconsistency branch from bc33701 to e1f60e9 Compare January 24, 2026 12:59
@dprevost-LMI dprevost-LMI force-pushed the fix-incorrect-typings-and-commands-inconsistency branch from 566d4e6 to 3feae32 Compare January 24, 2026 17:37
@dprevost-LMI dprevost-LMI marked this pull request as ready for review January 24, 2026 21:18
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Feb 1, 2026
@christian-bromann christian-bromann merged commit 53642c9 into webdriverio:main Feb 1, 2026
7 checks passed
@wdio-bot
Copy link
Contributor

wdio-bot commented Feb 1, 2026

Hey dprevost-LMI 👋

Thank you for your contribution to WebdriverIO! Your pull request has been marked as an "Expensable" contribution.

We've sent you an email with further instructions on how to claim your expenses from our development fund.
Please make sure to check your spam folder as well. If you have any questions, feel free to reach out to us at expense@webdriver.io or in the contributing channel on Discord.

We are looking forward to more contributions from you in the future 🙌

Have a nice day,
The WebdriverIO Team 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Expensable $25 💸 PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants