Skip to content

Commit 324b646

Browse files
authored
feat: define device methods natively on Appium::Driver (#1109)
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.
1 parent 5e60d97 commit 324b646

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Commit based release not is [release_notes.md](./release_notes.md)
33

44
Release tags are https://github.com/appium/ruby_lib/releases .
55

6+
## [Unreleased]
7+
- Define device methods (`lock`, `unlock`, `hide_keyboard`, `push_file`, `pull_file`, `background_app`, `shake`, etc.) natively on `Appium::Driver` via `def_delegators :driver`, replacing the implicit delegation previously set up by `extend ::Appium::Core::Device`. Paves the way for `ruby_lib_core` to drop its static compatibility list (appium/ruby_lib_core#97).
8+
69
## 16.1.1 - 2025-12-28
710
- Add deprecated mark for start_logs_broadcast/stop_logs_broadcast to use BiDi instead
811

lib/appium_lib/driver.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ class Test < Result
4040

4141
module Appium
4242
class Driver
43+
extend Forwardable
44+
45+
# Methods forwarded to the underlying Appium::Core::Base::Driver instance
46+
# (exposed via `#driver`). Previously these were wired up implicitly by
47+
# `extend ::Appium::Core::Device` through a static compatibility list in
48+
# `ruby_lib_core` (see appium/ruby_lib_core#97). Defining them here lets
49+
# `ruby_lib_core` eventually drop that list.
50+
CORE_BRIDGE_METHODS = %i[
51+
take_element_screenshot save_viewport_screenshot
52+
lock device_locked? unlock
53+
hide_keyboard is_keyboard_shown
54+
ime_activate ime_available_engines ime_active_engine ime_activated ime_deactivate
55+
get_settings update_settings
56+
within_context current_context available_contexts set_context
57+
push_file pull_file pull_folder
58+
keyevent press_keycode long_press_keycode
59+
match_images_features find_image_occurrence get_images_similarity compare_images
60+
app_strings background_app
61+
install_app remove_app app_installed? activate_app terminate_app
62+
app_state
63+
stop_recording_screen stop_and_save_recording_screen
64+
shake device_time
65+
execute_cdp
66+
].freeze
67+
68+
def_delegators :driver, *CORE_BRIDGE_METHODS
69+
4370
# @private
4471
class << self
4572
def convert_to_symbol(value)

0 commit comments

Comments
 (0)