Skip to content

Appium helper: setNetworkConnection / grabNetworkConnection trigger WebDriverIO deprecation warnings #5619

Description

@mirao

Description

When running Appium Android tests, the following deprecation warnings appear in the console for every test suite that calls I.setNetworkConnection() or I.grabNetworkConnection():

⚠️ [WEBDRIVERIO DEPRECATION NOTICE] For Appium Android automation, use `driver.execute('mobile: setConnectivity', { ... })` instead
⚠️ [WEBDRIVERIO DEPRECATION NOTICE] For Appium Android automation, use `driver.execute('mobile: getConnectivity', { ... })` instead

Root Cause

The deprecation is declared in @wdio/protocols (added in 9.27.2; not present in 9.16.2). WebDriverIO's command dispatch layer emits console.warn automatically whenever a protocol command has a deprecated field set.

The two affected methods in lib/helper/Appium.js:

// grabNetworkConnection — calls the deprecated WebDriverIO protocol method
async grabNetworkConnection() {
  onlyForApps.call(this, supportedPlatform.android)
  const res = await this.browser.getNetworkConnection()   // ← deprecated
  return { value: res, inAirplaneMode: res.inAirplaneMode, hasWifi: res.hasWifi, hasData: res.hasData }
}

// setNetworkConnection — same issue
async setNetworkConnection(value) {
  onlyForApps.call(this, supportedPlatform.android)
  return this.browser.setNetworkConnection(value)         // ← deprecated
}

Suggested Fix

Replace the deprecated WebDriverIO protocol calls with the recommended Appium mobile execute commands.

setNetworkConnection — decode the existing bitmask and forward to mobile: setConnectivity:

async setNetworkConnection(value) {
  onlyForApps.call(this, supportedPlatform.android)
  return this.browser.execute('mobile: setConnectivity', {
    airplaneMode: !!(value & 1),
    wifi:         !!(value & 2),
    data:         !!(value & 4),
  })
}

Bitmask mapping (matches the existing JSDoc):

value airplaneMode wifi data
0 false false false
1 true false false
2 false true false
4 false false true
6 false true true

grabNetworkConnection — use mobile: getConnectivity:

async grabNetworkConnection() {
  onlyForApps.call(this, supportedPlatform.android)
  return this.browser.execute('mobile: getConnectivity')
}

Note: The return shape of grabNetworkConnection changes — mobile: getConnectivity returns { wifi, data, airplaneMode } instead of the old numeric bitmask — but this is a breaking change only for callers that inspect the raw value.

Environment

  • CodeceptJS: 4.0.6
  • WebDriverIO: 9.27.2
  • @wdio/protocols: 9.27.2 (deprecation field added here)
  • Appium: Android

Notes

  • The commands still work — this is a warning only, not a functional regression.
  • The issue was not visible with CodeceptJS 3.x because @wdio/protocols 9.16.2 (used then) did not yet have the deprecated field on these commands.
  • Happy to open a PR with the fix if this approach looks good.

Reported by Claude Code (claude-sonnet-4-6) on behalf of a user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions