From b529bbb30fb232ed33df682c8e773f5e201e7da2 Mon Sep 17 00:00:00 2001 From: theluckystrike <51033404+theluckystrike@users.noreply.github.com> Date: Thu, 8 Oct 2026 06:31:46 +0000 Subject: [PATCH] fix(android): send the gsmVoice and powerAc execute method names set_gsm_voice sent `mobile: gmsVoice` (letters transposed) and set_power_ac sent `mobile: powerAC`. appium-android-driver registers `mobile: gsmVoice` and `mobile: powerAc` in its executeMethodMap, which UiAutomator2 and Espresso inherit, and BaseDriver.executeMethod looks the name up exactly. Both calls failed with UnknownMethodException and the emulator state didn't change. I fixed both names in appium/webdriver/extensions/android/gsm.py and power.py (plus the powerAc docstring), asserted the script name in test_set_gsm_voice and corrected the expected name in test_set_power_ac. Tests I ran $ uv run python -m pytest test/unit/webdriver/device/gsm_test.py test/unit/webdriver/device/power_test.py (extensions from master 4a4c46b) E AssertionError: assert 'mobile: gmsVoice' == 'mobile: gsmVoice' E AssertionError: assert 'mobile: powerAC' == 'mobile: powerAc' 2 failed, 3 passed $ uv run python -m pytest test/unit (this branch) 202 passed $ uv run ruff check . All checks passed $ uv run ruff format (check mode) 394 files already formatted $ uv run mypy appium Success, no issues found in 320 source files End to end, the client against AndroidDriver.execute() from appium-android-driver 14.2.3 behind a local HTTP shim (adb stubbed, no emulator) master set_power_ac UnknownMethodException Unsupported execute method 'mobile: powerAC', did you mean 'mobile: powerAc'? set_gsm_voice UnknownMethodException Unsupported execute method 'mobile: gmsVoice', did you mean 'mobile: gsmVoice'? branch set_power_ac OK, driver calls adb.powerAC(off) set_gsm_voice OK, driver calls adb.gsmVoice(roaming) Not run against a real emulator. --- appium/webdriver/extensions/android/gsm.py | 2 +- appium/webdriver/extensions/android/power.py | 4 ++-- test/unit/webdriver/device/gsm_test.py | 1 + test/unit/webdriver/device/power_test.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/appium/webdriver/extensions/android/gsm.py b/appium/webdriver/extensions/android/gsm.py index 56aedbd5..5dfc9a5d 100644 --- a/appium/webdriver/extensions/android/gsm.py +++ b/appium/webdriver/extensions/android/gsm.py @@ -113,7 +113,7 @@ def set_gsm_voice(self, state: str) -> Self: Returns: Union['WebDriver', 'Gsm']: Self instance """ - ext_name = 'mobile: gmsVoice' + ext_name = 'mobile: gsmVoice' constants = extract_const_attributes(GsmVoiceState) if state not in constants.values(): logger.warning( diff --git a/appium/webdriver/extensions/android/power.py b/appium/webdriver/extensions/android/power.py index 7b8b574e..6c0b1222 100644 --- a/appium/webdriver/extensions/android/power.py +++ b/appium/webdriver/extensions/android/power.py @@ -47,7 +47,7 @@ def set_power_ac(self, ac_state: str) -> Self: Android only. - Requires the Appium driver to support the `mobile: powerAC` execute method. + Requires the Appium driver to support the `mobile: powerAc` execute method. Args: ac_state: The power ac state to be set. Use `Power.AC_OFF`, `Power.AC_ON` @@ -59,7 +59,7 @@ def set_power_ac(self, ac_state: str) -> Self: Returns: Union['WebDriver', 'Power']: Self instance """ - ext_name = 'mobile: powerAC' + ext_name = 'mobile: powerAc' args = {'state': ac_state} self.execute_script(ext_name, args) return self diff --git a/test/unit/webdriver/device/gsm_test.py b/test/unit/webdriver/device/gsm_test.py index b40f2df5..777946d2 100644 --- a/test/unit/webdriver/device/gsm_test.py +++ b/test/unit/webdriver/device/gsm_test.py @@ -67,4 +67,5 @@ def test_set_gsm_voice(self): assert isinstance(driver.set_gsm_voice(GsmVoiceState.ROAMING), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) + assert d['script'] == 'mobile: gsmVoice' assert d['args'][0]['state'] == GsmVoiceState.ROAMING diff --git a/test/unit/webdriver/device/power_test.py b/test/unit/webdriver/device/power_test.py index ea5fe1dc..f96fcd5d 100644 --- a/test/unit/webdriver/device/power_test.py +++ b/test/unit/webdriver/device/power_test.py @@ -43,5 +43,5 @@ def test_set_power_ac(self): assert isinstance(driver.set_power_ac(Power.AC_ON), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) - assert d['script'] == 'mobile: powerAC' + assert d['script'] == 'mobile: powerAc' assert d['args'][0]['state'] == Power.AC_ON