Skip to content

fix(appium): replace deprecated setNetworkConnection/getNetworkConnection with mobile: setConnectivity/getConnectivity - #5662

Merged
DenysKuchma merged 1 commit into
codeceptjs:4.xfrom
mirao:fix/5619-appium-network-connection-deprecation
Jul 30, 2026
Merged

fix(appium): replace deprecated setNetworkConnection/getNetworkConnection with mobile: setConnectivity/getConnectivity#5662
DenysKuchma merged 1 commit into
codeceptjs:4.xfrom
mirao:fix/5619-appium-network-connection-deprecation

Conversation

@mirao

@mirao mirao commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the deprecated WebdriverIO getNetworkConnection/setNetworkConnection protocol calls in Appium.grabNetworkConnection()/Appium.setNetworkConnection() with the recommended Appium mobile: getConnectivity/mobile: setConnectivity execute commands, removing the [WEBDRIVERIO DEPRECATION NOTICE] console warnings introduced by @wdio/protocols 9.27.2+.
  • grabNetworkConnection() keeps its original return shape (value/inAirplaneMode/hasWifi/hasData) by re-encoding the new {wifi, data, airplaneMode} response back into the legacy bitmask, so existing test code that inspects .value isn't broken.
  • Command names and parameter shapes were verified against the actual appium-android-driver source (execute-method-map.ts, commands/network.ts).

Known limitation

mobile: setConnectivity/mobile: getConnectivity were added to appium-android-driver in April 2023. Users still running with appiumV2: false (Appium 1.x, unmaintained since 2022) will not have these commands available on the server side.

Fixes #5619

Test plan

  • Added test/unit/helper/Appium_networkConnection_test.js covering the bitmask encode/decode logic for both methods and the Android platform guard
  • npx mocha test/unit/helper/Appium_networkConnection_test.js passes (8/8)
  • npx prettier --check lib/helper/Appium.js test/unit/helper/Appium_networkConnection_test.js passes
  • Real-device verification against Sauce Labs Android (existing tests in test/helper/Appium_test.js cover this method but are not currently tagged @quick/@second, so they don't run in CI — pre-existing gap, unrelated to this change)

…tion with mobile: setConnectivity/getConnectivity

WebdriverIO 9.27.2+ emits deprecation warnings for the legacy Android
network connection protocol commands. Appium's recommended replacement
is the mobile: setConnectivity / mobile: getConnectivity execute
commands.

grabNetworkConnection() keeps its original return shape
(value/inAirplaneMode/hasWifi/hasData) by re-encoding the new
{wifi, data, airplaneMode} response into the legacy bitmask, so
existing test code isn't broken.

Fixes codeceptjs#5619
@mirao

mirao commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

The failed unit test in NodeJS 26.x (https://github.com/codeceptjs/CodeceptJS/actions/runs/29249150059/job/86813168615?pr=5662) doesn't seem to be related to my fix.

@DenysKuchma
DenysKuchma merged commit ccc8b3c into codeceptjs:4.x Jul 30, 2026
13 of 16 checks passed
DavertMik pushed a commit that referenced this pull request Sep 8, 2026
…) (#5678)

`mobile: setConnectivity` runs `adb shell svc <type> <state>` for every
field it is passed, so always sending `data` made setNetworkConnection()
fail with "Can't find service: phone" (adb exit 20) on system images
without telephony, such as tablet emulators. This regressed in 4.1.0,
when #5662 replaced the legacy setNetworkConnection command, which
tolerated the missing phone service.

Probe `mobile: deviceInfo` for a carrier and only send `data` when the
device actually has telephony. Dropping `data` unconditionally is not an
option: on a telephony-capable device it leaves cellular up, so going
offline silently does nothing and tests keep passing against a device
that is still online.

Only a positive probe result is cached. A freshly booted device may not
have registered a carrier yet, and since the first call typically comes
from a suite-setup hook seconds after boot, caching that negative would
strip `data` for the rest of the session on a real phone. Guarding with
`!this._hasTelephony` re-asks until a carrier appears, then stops.

Co-authored-by: Jaromir Obr <jobr@spork.tech>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Appium helper: setNetworkConnection / grabNetworkConnection trigger WebDriverIO deprecation warnings

2 participants