Skip to content

feat: define device methods natively on Appium::Driver#1109

Merged
KazuCocoa merged 1 commit intoappium:masterfrom
aguspe:feat/define-device-methods
Apr 19, 2026
Merged

feat: define device methods natively on Appium::Driver#1109
KazuCocoa merged 1 commit intoappium:masterfrom
aguspe:feat/define-device-methods

Conversation

@aguspe
Copy link
Copy Markdown
Contributor

@aguspe aguspe commented Apr 19, 2026

Description

This PR defines the device layer methods natively on Appium::Driver via def_delegators :driver instead of relying on them being set up implicitly by extend ::Appium::Core::Device which walks a static list in ruby_lib_core/lib/appium_lib_core/device.rb#L26-L42

The methods covered are the same ones that list covers lock unlock device_locked? hide_keyboard is_keyboard_shown push_file pull_file pull_folder background_app shake press_keycode keyevent long_press_keycode the ime_* group the context group app_strings install_app remove_app app_installed? activate_app terminate_app app_state stop_recording_screen stop_and_save_recording_screen device_time execute_cdp take_element_screenshot save_viewport_screenshot and the image comparison methods

execute_driver is intentionally not in the delegator list because Appium::Driver already defines its own execute_driver (driver.rb:711) and we want to keep that one

The extend ::Appium::Core::Device call in initialize is kept because it is still needed for the platform specific endpoints that get added through add_endpoint_method like touch_id clipboard etc

Motivation and Context

Following up on appium/ruby_lib_core#97

@KazuCocoa mentioned there that the cleanest way forward is to first define these methods on ruby_lib side and then we can remove the static list in ruby_lib_core so this PR is that first step

Once this is merged I will open the follow up PR to ruby_lib_core to drop the list

Happy to adjust anything if you prefer a different approach

Adds explicit `def_delegators :driver, ...` for device-layer methods
(lock/unlock, hide_keyboard, push_file, pull_file, background_app,
shake, press_keycode, ime_*, context_*, app_strings, install_app, etc.)
that were previously wired up only implicitly by
`extend ::Appium::Core::Device` via a static compatibility list in
ruby_lib_core (lib/appium_lib_core/device.rb:26-42).

Defining them here lets ruby_lib_core drop that list
(appium/ruby_lib_core#97), which every new bridge endpoint currently
has to be added to by hand.

Native `Appium::Driver#execute_driver` (driver.rb:711) continues to
win over the class-level delegator since Ruby redefines methods in
source order.
@aguspe aguspe requested a review from KazuCocoa as a code owner April 19, 2026 13:40
@KazuCocoa
Copy link
Copy Markdown
Member

lg 👍
I'll create a new release with this

@KazuCocoa KazuCocoa merged commit 324b646 into appium:master Apr 19, 2026
9 of 10 checks passed
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.

2 participants