Skip to content

refactor!: remove legacy implementation - #1267

Open
KazuCocoa wants to merge 5 commits into
masterfrom
remove-todo
Open

refactor!: remove legacy implementation#1267
KazuCocoa wants to merge 5 commits into
masterfrom
remove-todo

Conversation

@KazuCocoa

@KazuCocoa KazuCocoa commented Aug 2, 2026

Copy link
Copy Markdown
Member

Closes #1221

As same as other PRs such as #1258 so we can release a new version

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the “W3C-only” refactor pattern (as in #1258) by removing legacy MJSONWP endpoint fallbacks and command registrations from multiple Appium Python client extensions, and updating unit tests to expect W3C execute/sync script-based behavior.

Changes:

  • Removed legacy UnknownMethodException fallback paths and CanRememberExtensionPresence usage across several extension modules, leaving only execute_script('mobile: ...') code paths.
  • Removed legacy endpoint command registrations (_add_commands) where they existed or were no-ops.
  • Updated/trimmed unit tests to stop stubbing legacy endpoints and, in several cases, assert the W3C mobile script + argument payloads.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/unit/webdriver/performance_test.py Updates performance tests to expect W3C execute/sync and assert mobile: getPerformanceData.
test/unit/webdriver/device/system_bars_test.py Switches system bars test stubbing from legacy endpoint to W3C execute/sync.
test/unit/webdriver/device/sms_test.py Updates SMS test to validate mobile: sendSms script payload.
test/unit/webdriver/device/shake_test.py Switches shake test stubbing to W3C execute/sync.
test/unit/webdriver/device/remote_fs_test.py Updates remote FS tests to validate mobile: pushFile/pullFile/pullFolder scripts and args.
test/unit/webdriver/device/power_test.py Updates power tests to validate mobile: powerCapacity/powerAC scripts and args.
test/unit/webdriver/device/lock_test.py Updates lock/unlock/isLocked tests to validate W3C mobile scripts and remove legacy endpoint stubs.
test/unit/webdriver/device/keyboard_test.py Updates keyboard-related tests to validate W3C mobile: pressKey/hideKeyboard behaviors.
test/unit/webdriver/device/fingerprint_test.py Updates fingerprint test to validate mobile: fingerprint script payload.
test/unit/webdriver/device/display_test.py Switches display density test stubbing to W3C execute/sync.
test/unit/webdriver/device/device_time_test.py Switches device time tests to W3C execute/sync and asserts formatted-time args.
test/unit/webdriver/device/clipboard_test.py Switches clipboard tests to W3C execute/sync stubs (removing legacy endpoint stubs).
test/unit/webdriver/device/activities_test.py Switches activities tests to W3C execute/sync stubs (removing legacy endpoint stubs).
appium/webdriver/extensions/remote_fs.py Removes legacy endpoint fallbacks/registrations; uses only mobile: pushFile/pullFile/pullFolder.
appium/webdriver/extensions/keyboard.py Removes legacy endpoint fallback logic; uses only W3C scripts for keyboard actions.
appium/webdriver/extensions/hw_actions.py Removes legacy endpoint fallback logic; uses only W3C scripts for hardware actions.
appium/webdriver/extensions/device_time.py Removes legacy endpoint fallbacks/registrations; uses only mobile: getDeviceTime.
appium/webdriver/extensions/clipboard.py Removes legacy endpoint fallback logic; uses only mobile: setClipboard/getClipboard.
appium/webdriver/extensions/applications.py Removes no-op _add_commands method.
appium/webdriver/extensions/android/system_bars.py Removes legacy endpoint fallback/registration; uses only mobile: getSystemBars.
appium/webdriver/extensions/android/sms.py Removes legacy endpoint fallback/registration; uses only mobile: sendSms.
appium/webdriver/extensions/android/power.py Removes legacy endpoint fallback/registration; uses only mobile: powerCapacity/powerAC.
appium/webdriver/extensions/android/performance.py Removes legacy endpoint fallback/registration; uses only mobile: getPerformanceData/getPerformanceDataTypes.
appium/webdriver/extensions/android/network.py Removes no-op _add_commands method.
appium/webdriver/extensions/android/gsm.py Removes no-op _add_commands method.
appium/webdriver/extensions/android/display.py Removes legacy endpoint fallback/registration; uses only mobile: getDisplayDensity.
appium/webdriver/extensions/android/common.py Removes no-op _add_commands method.
appium/webdriver/extensions/android/activities.py Removes legacy endpoint fallback/registration; uses only mobile: getCurrentActivity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread appium/webdriver/extensions/android/performance.py
Comment thread test/unit/webdriver/performance_test.py
Comment on lines 36 to 37
Union['WebDriver', 'Keyboard']: Self instance
"""

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated no new comments.

Suppressed comments (12)

test/unit/webdriver/device/clipboard_test.py:42

  • This clipboard text test asserts the args payload but not the W3C execute script name. Add a mobile: setClipboard script assertion so the test enforces the intended command path.
    @httpretty.activate
    def test_set_clipboard_text(self):
        driver = ios_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),

test/unit/webdriver/device/system_bars_test.py:33

  • This test validates the returned system bars payload but does not assert the request used the W3C execute script name (mobile: getSystemBars). Add a script assertion (and import the helper) so the test enforces the W3C-only refactor.
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),
            body=body,
        )

test/unit/webdriver/device/activities_test.py:28

  • These activity tests validate return values but do not assert that the W3C execute script (mobile: getCurrentActivity) was used. Add request-body assertions (and import the helper) so the tests enforce the W3C-only path.
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),
            body='{"value": ".ExampleActivity"}',
        )

test/unit/webdriver/device/lock_test.py:79

  • lock_no_args and is_locked tests (iOS) don't assert which W3C scripts were invoked, so they won't catch regressions back to legacy endpoints. Add request-body assertions for mobile: lock (seconds=0) and mobile: isLocked.
    def test_lock_no_args(self):
        driver = ios_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
        driver.lock()

    @httpretty.activate
    def test_islocked_false(self):
        driver = ios_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": false}')
        assert driver.is_locked() is False

test/unit/webdriver/device/keyboard_test.py:27

  • test_hide_keyboard (Android) currently doesn't assert which execute script was invoked. Adding a request-body assertion for mobile: hideKeyboard makes the test enforce the new W3C-only behavior.
    def test_hide_keyboard(self):
        driver = android_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
        assert isinstance(driver.hide_keyboard(), WebDriver)

appium/webdriver/extensions/android/display.py:32

  • The get_display_density docstring now contains both a Returns: section and a separate Return: section describing the same value, which is redundant and inconsistent. Consolidate into a single Returns: block.
        Returns:
            The display density of the Android device(dpi)

        Usage:
            self.driver.get_display_density()

        Return:
            int: The display density

test/unit/webdriver/performance_test.py:41

  • test_get_performance_data_types doesn't assert which W3C extension script was executed, so it could pass even if the implementation regresses away from mobile: getPerformanceDataTypes. Add a request-body assertion for the executed script.
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),

test/unit/webdriver/device/device_time_test.py:26

  • The device_time and get_device_time() tests validate return values but don't assert the W3C execute script (mobile: getDeviceTime) was called (with no args). Adding request-body assertions ensures these tests actually enforce the W3C-only refactor.
    @httpretty.activate
    def test_device_time(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),

test/unit/webdriver/device/clipboard_test.py:27

  • This clipboard test asserts the args payload but not the W3C execute script name. Add a mobile: setClipboard script assertion so the test enforces the intended command path.

This issue also appears on line 37 of the same file.

    @httpretty.activate
    def test_set_clipboard_with_url(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),

test/unit/webdriver/device/shake_test.py:28

  • The shake unit test only checks the return type; add a request-body assertion for mobile: shake (and import the helper) so the test enforces the W3C-only command path.
    def test_shake(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/execute/sync'),

test/unit/webdriver/device/display_test.py:25

  • This test validates the return value but does not assert the W3C extension script (mobile: getDisplayDensity) was used. Add a request-body assertion (and import the helper) so regressions back to the legacy endpoint are caught.
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": 560}')
        assert driver.get_display_density() == 560

test/unit/webdriver/device/lock_test.py:42

  • lock_no_args and is_locked tests (Android) don't assert which W3C scripts were invoked, so they won't catch regressions back to legacy endpoints. Add request-body assertions for mobile: lock (seconds=0) and mobile: isLocked.

This issue also appears on line 70 of the same file.

    def test_lock_no_args(self):
        driver = android_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
        driver.lock()

    @httpretty.activate
    def test_islocked_false(self):
        driver = android_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": false}')
        assert driver.is_locked() is False

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.

Stop auto release til merge all of TODO: Remove the fallback removal

2 participants