appium_lib_core 4.1.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +250 -271
  3. data/README.md +65 -15
  4. data/Rakefile +4 -0
  5. data/appium_lib_core.gemspec +5 -8
  6. data/bin/console +0 -4
  7. data/lib/appium_lib_core/android/device/auth_finger_print.rb +2 -1
  8. data/lib/appium_lib_core/android/device.rb +45 -4
  9. data/lib/appium_lib_core/common/base/bridge.rb +320 -90
  10. data/lib/appium_lib_core/common/base/capabilities.rb +8 -9
  11. data/lib/appium_lib_core/common/base/device_ime.rb +49 -0
  12. data/lib/appium_lib_core/common/base/driver.rb +232 -191
  13. data/lib/appium_lib_core/common/base/driver_settings.rb +51 -0
  14. data/lib/appium_lib_core/common/base/has_location.rb +80 -0
  15. data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
  16. data/lib/appium_lib_core/common/base/http_default.rb +15 -38
  17. data/lib/appium_lib_core/{ios/uiautomation/bridge.rb → common/base/remote_status.rb} +9 -8
  18. data/lib/appium_lib_core/common/base/rotable.rb +62 -0
  19. data/lib/appium_lib_core/common/base/screenshot.rb +8 -8
  20. data/lib/appium_lib_core/common/base/search_context.rb +20 -6
  21. data/lib/appium_lib_core/common/base.rb +1 -3
  22. data/lib/appium_lib_core/common/command.rb +259 -4
  23. data/lib/appium_lib_core/common/device/app_management.rb +8 -14
  24. data/lib/appium_lib_core/common/device/image_comparison.rb +12 -4
  25. data/lib/appium_lib_core/common/device/keyevent.rb +4 -4
  26. data/lib/appium_lib_core/common/{command/mjsonwp.rb → device/orientation.rb} +14 -11
  27. data/lib/appium_lib_core/common/device/touch_actions.rb +2 -0
  28. data/lib/appium_lib_core/common/device/value.rb +6 -8
  29. data/lib/appium_lib_core/common/error.rb +4 -5
  30. data/lib/appium_lib_core/common/log.rb +4 -1
  31. data/lib/appium_lib_core/common/touch_action/multi_touch.rb +19 -0
  32. data/lib/appium_lib_core/common/touch_action/touch_actions.rb +16 -2
  33. data/lib/appium_lib_core/common/wait.rb +38 -6
  34. data/lib/appium_lib_core/device.rb +1 -5
  35. data/lib/appium_lib_core/driver.rb +194 -108
  36. data/lib/appium_lib_core/{patch.rb → element.rb} +66 -9
  37. data/lib/appium_lib_core/{common/base/command.rb → mac2/bridge.rb} +9 -8
  38. data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
  39. data/lib/appium_lib_core/mac2/device.rb +92 -0
  40. data/lib/appium_lib_core/{ios.rb → mac2.rb} +2 -5
  41. data/lib/appium_lib_core/support/event_firing_bridge.rb +57 -0
  42. data/lib/appium_lib_core/version.rb +2 -2
  43. data/lib/appium_lib_core/windows/device/app_management.rb +38 -0
  44. data/lib/appium_lib_core/windows/device.rb +2 -0
  45. data/lib/appium_lib_core.rb +21 -10
  46. metadata +31 -86
  47. data/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
  48. data/.github/contributing.md +0 -26
  49. data/.github/issue_template.md +0 -20
  50. data/.github/workflows/unittest.yml +0 -68
  51. data/.gitignore +0 -18
  52. data/.rubocop.yml +0 -58
  53. data/azure-pipelines.yml +0 -15
  54. data/ci-jobs/functional/android_setup.yml +0 -3
  55. data/ci-jobs/functional/ios_setup.yml +0 -7
  56. data/ci-jobs/functional/publish_test_result.yml +0 -18
  57. data/ci-jobs/functional/run_appium.yml +0 -25
  58. data/ci-jobs/functional/start-emulator.sh +0 -26
  59. data/ci-jobs/functional_test.yml +0 -298
  60. data/docs/mobile_command.md +0 -34
  61. data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -81
  62. data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -252
  63. data/lib/appium_lib_core/common/command/common.rb +0 -110
  64. data/lib/appium_lib_core/common/command/w3c.rb +0 -56
  65. data/lib/appium_lib_core/ios/uiautomation/device.rb +0 -44
  66. data/lib/appium_lib_core/ios/uiautomation/patch.rb +0 -34
  67. data/release_notes.md +0 -816
  68. data/script/commands.rb +0 -200
@@ -12,7 +12,262 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'base/command'
16
- require_relative 'command/common'
17
- require_relative 'command/mjsonwp'
18
- require_relative 'command/w3c'
15
+ module Appium
16
+ module Core
17
+ # ref: https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/routes.js
18
+ module Commands
19
+ # Some commands differ for each driver.
20
+ COMMAND = {
21
+ ###
22
+ # W3C
23
+ ###
24
+ status: [:get, 'status'],
25
+
26
+ #
27
+ # session handling
28
+ #
29
+
30
+ new_session: [:post, 'session'],
31
+ delete_session: [:delete, 'session/:session_id'],
32
+
33
+ #
34
+ # basic driver
35
+ #
36
+
37
+ get: [:post, 'session/:session_id/url'],
38
+ get_current_url: [:get, 'session/:session_id/url'],
39
+ back: [:post, 'session/:session_id/back'],
40
+ forward: [:post, 'session/:session_id/forward'],
41
+ refresh: [:post, 'session/:session_id/refresh'],
42
+ get_title: [:get, 'session/:session_id/title'],
43
+
44
+ #
45
+ # window and Frame handling
46
+ #
47
+
48
+ get_window_handle: [:get, 'session/:session_id/window'],
49
+ new_window: [:post, 'session/:session_id/window/new'],
50
+ close_window: [:delete, 'session/:session_id/window'],
51
+ switch_to_window: [:post, 'session/:session_id/window'],
52
+ get_window_handles: [:get, 'session/:session_id/window/handles'],
53
+ fullscreen_window: [:post, 'session/:session_id/window/fullscreen'],
54
+ minimize_window: [:post, 'session/:session_id/window/minimize'],
55
+ maximize_window: [:post, 'session/:session_id/window/maximize'],
56
+ set_window_size: [:post, 'session/:session_id/window/size'],
57
+ get_window_size: [:get, 'session/:session_id/window/size'],
58
+ set_window_position: [:post, 'session/:session_id/window/position'],
59
+ get_window_position: [:get, 'session/:session_id/window/position'],
60
+ set_window_rect: [:post, 'session/:session_id/window/rect'],
61
+ get_window_rect: [:get, 'session/:session_id/window/rect'],
62
+ switch_to_frame: [:post, 'session/:session_id/frame'],
63
+ switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'],
64
+
65
+ #
66
+ # element
67
+ #
68
+
69
+ find_element: [:post, 'session/:session_id/element'],
70
+ find_elements: [:post, 'session/:session_id/elements'],
71
+ find_child_element: [:post, 'session/:session_id/element/:id/element'],
72
+ find_child_elements: [:post, 'session/:session_id/element/:id/elements'],
73
+ find_shadow_child_element: [:post, 'session/:session_id/shadow/:id/element'],
74
+ find_shadow_child_elements: [:post, 'session/:session_id/shadow/:id/elements'],
75
+ get_active_element: [:get, 'session/:session_id/element/active'],
76
+ is_element_selected: [:get, 'session/:session_id/element/:id/selected'],
77
+ get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
78
+ get_element_property: [:get, 'session/:session_id/element/:id/property/:name'],
79
+ get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'],
80
+ get_element_aria_role: [:get, 'session/:session_id/element/:id/computedrole'],
81
+ get_element_aria_label: [:get, 'session/:session_id/element/:id/computedlabel'],
82
+ get_element_text: [:get, 'session/:session_id/element/:id/text'],
83
+ get_element_tag_name: [:get, 'session/:session_id/element/:id/name'],
84
+ get_element_rect: [:get, 'session/:session_id/element/:id/rect'],
85
+ is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'],
86
+
87
+ #
88
+ # document handling
89
+ #
90
+
91
+ get_page_source: [:get, 'session/:session_id/source'],
92
+ execute_script: [:post, 'session/:session_id/execute/sync'],
93
+ execute_async_script: [:post, 'session/:session_id/execute/async'],
94
+
95
+ #
96
+ # cookies
97
+ #
98
+
99
+ get_all_cookies: [:get, 'session/:session_id/cookie'],
100
+ get_cookie: [:get, 'session/:session_id/cookie/:name'],
101
+ add_cookie: [:post, 'session/:session_id/cookie'],
102
+ delete_cookie: [:delete, 'session/:session_id/cookie/:name'],
103
+ delete_all_cookies: [:delete, 'session/:session_id/cookie'],
104
+
105
+ #
106
+ # timeouts
107
+ #
108
+
109
+ set_timeout: [:post, 'session/:session_id/timeouts'],
110
+
111
+ #
112
+ # actions
113
+ #
114
+
115
+ actions: [:post, 'session/:session_id/actions'],
116
+ release_actions: [:delete, 'session/:session_id/actions'],
117
+ print_page: [:post, 'session/:session_id/print'],
118
+
119
+ #
120
+ # Element Operations
121
+ #
122
+
123
+ element_click: [:post, 'session/:session_id/element/:id/click'],
124
+ element_tap: [:post, 'session/:session_id/element/:id/tap'],
125
+ element_clear: [:post, 'session/:session_id/element/:id/clear'],
126
+ element_send_keys: [:post, 'session/:session_id/element/:id/value'],
127
+
128
+ #
129
+ # alerts
130
+ #
131
+
132
+ dismiss_alert: [:post, 'session/:session_id/alert/dismiss'],
133
+ accept_alert: [:post, 'session/:session_id/alert/accept'],
134
+ get_alert_text: [:get, 'session/:session_id/alert/text'],
135
+ send_alert_text: [:post, 'session/:session_id/alert/text'],
136
+
137
+ #
138
+ # screenshot
139
+ #
140
+
141
+ take_screenshot: [:get, 'session/:session_id/screenshot'],
142
+ take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'],
143
+
144
+ #
145
+ # server extensions
146
+ #
147
+
148
+ upload_file: [:post, 'session/:session_id/se/file'],
149
+
150
+ ###
151
+ # Used by Appium, but no in W3C
152
+ ###
153
+
154
+ # ::Appium::Core::Base::Commands::OSS has the following commands and Appium also use them.
155
+ # Delegated to ::Appium::Core::Base::Commands::OSS commands
156
+ is_element_displayed: [:get, 'session/:session_id/element/:id/displayed'], # hint: https://w3c.github.io/webdriver/#element-displayedness
157
+
158
+ get_timeouts: [:get, 'session/:session_id/timeouts'], # https://w3c.github.io/webdriver/#get-timeouts
159
+
160
+ # Add OSS commands to W3C commands. We can remove them if we would like to remove them from W3C module.
161
+ ### Session capability
162
+ get_capabilities: [:get, 'session/:session_id'],
163
+
164
+ ### rotatable
165
+ get_screen_orientation: [:get, 'session/:session_id/orientation'],
166
+ set_screen_orientation: [:post, 'session/:session_id/orientation'],
167
+
168
+ get_location: [:get, 'session/:session_id/location'],
169
+ set_location: [:post, 'session/:session_id/location'],
170
+
171
+ ### For IME
172
+ ime_get_available_engines: [:get, 'session/:session_id/ime/available_engines'],
173
+ ime_get_active_engine: [:get, 'session/:session_id/ime/active_engine'],
174
+ ime_is_activated: [:get, 'session/:session_id/ime/activated'],
175
+ ime_deactivate: [:post, 'session/:session_id/ime/deactivate'],
176
+ ime_activate_engine: [:post, 'session/:session_id/ime/activate'],
177
+
178
+ ### Logs
179
+ get_available_log_types: [:get, 'session/:session_id/log/types'],
180
+ get_log: [:post, 'session/:session_id/log'],
181
+
182
+ ###
183
+ # Appium own
184
+ ###
185
+
186
+ # common
187
+ get_all_sessions: [:get, 'sessions'],
188
+ available_contexts: [:get, 'session/:session_id/contexts'],
189
+ set_context: [:post, 'session/:session_id/context'],
190
+ current_context: [:get, 'session/:session_id/context'],
191
+
192
+ touch_actions: [:post, 'session/:session_id/touch/perform'],
193
+ multi_touch: [:post, 'session/:session_id/touch/multi/perform'],
194
+
195
+ set_immediate_value: [:post, 'session/:session_id/appium/element/:id/value'],
196
+ replace_value: [:post, 'session/:session_id/appium/element/:id/replace_value'],
197
+
198
+ launch_app: [:post, 'session/:session_id/appium/app/launch'],
199
+ close_app: [:post, 'session/:session_id/appium/app/close'],
200
+ reset: [:post, 'session/:session_id/appium/app/reset'],
201
+ background_app: [:post, 'session/:session_id/appium/app/background'],
202
+ app_strings: [:post, 'session/:session_id/appium/app/strings'],
203
+
204
+ device_locked?: [:post, 'session/:session_id/appium/device/is_locked'],
205
+ unlock: [:post, 'session/:session_id/appium/device/unlock'],
206
+ lock: [:post, 'session/:session_id/appium/device/lock'],
207
+ device_time: [:get, 'session/:session_id/appium/device/system_time'],
208
+ install_app: [:post, 'session/:session_id/appium/device/install_app'],
209
+ remove_app: [:post, 'session/:session_id/appium/device/remove_app'],
210
+ app_installed?: [:post, 'session/:session_id/appium/device/app_installed'],
211
+ activate_app: [:post, 'session/:session_id/appium/device/activate_app'],
212
+ terminate_app: [:post, 'session/:session_id/appium/device/terminate_app'],
213
+ app_state: [:post, 'session/:session_id/appium/device/app_state'],
214
+ shake: [:post, 'session/:session_id/appium/device/shake'],
215
+ hide_keyboard: [:post, 'session/:session_id/appium/device/hide_keyboard'],
216
+ press_keycode: [:post, 'session/:session_id/appium/device/press_keycode'],
217
+ long_press_keycode: [:post, 'session/:session_id/appium/device/long_press_keycode'],
218
+ push_file: [:post, 'session/:session_id/appium/device/push_file'],
219
+ pull_file: [:post, 'session/:session_id/appium/device/pull_file'],
220
+ pull_folder: [:post, 'session/:session_id/appium/device/pull_folder'],
221
+ get_clipboard: [:post, 'session/:session_id/appium/device/get_clipboard'],
222
+ set_clipboard: [:post, 'session/:session_id/appium/device/set_clipboard'],
223
+ finger_print: [:post, 'session/:session_id/appium/device/finger_print'],
224
+ get_settings: [:get, 'session/:session_id/appium/settings'],
225
+ update_settings: [:post, 'session/:session_id/appium/settings'],
226
+ stop_recording_screen: [:post, 'session/:session_id/appium/stop_recording_screen'],
227
+ start_recording_screen: [:post, 'session/:session_id/appium/start_recording_screen'],
228
+ compare_images: [:post, 'session/:session_id/appium/compare_images'],
229
+ is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'],
230
+ execute_driver: [:post, 'session/:session_id/appium/execute_driver'],
231
+ post_log_event: [:post, 'session/:session_id/appium/log_event'],
232
+ get_log_events: [:post, 'session/:session_id/appium/events']
233
+ }.freeze
234
+
235
+ COMMAND_ANDROID = {
236
+ open_notifications: [:post, 'session/:session_id/appium/device/open_notifications'],
237
+ toggle_airplane_mode: [:post, 'session/:session_id/appium/device/toggle_airplane_mode'],
238
+ start_activity: [:post, 'session/:session_id/appium/device/start_activity'],
239
+ current_activity: [:get, 'session/:session_id/appium/device/current_activity'],
240
+ current_package: [:get, 'session/:session_id/appium/device/current_package'],
241
+ get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'],
242
+ get_display_density: [:get, 'session/:session_id/appium/device/display_density'],
243
+ toggle_wifi: [:post, 'session/:session_id/appium/device/toggle_wifi'],
244
+ toggle_data: [:post, 'session/:session_id/appium/device/toggle_data'],
245
+ toggle_location_services: [:post, 'session/:session_id/appium/device/toggle_location_services'],
246
+ end_coverage: [:post, 'session/:session_id/appium/app/end_test_coverage'],
247
+ get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'],
248
+ get_performance_data: [:post, 'session/:session_id/appium/getPerformanceData'],
249
+ get_network_connection: [:get, 'session/:session_id/network_connection'], # defined also in OSS
250
+ set_network_connection: [:post, 'session/:session_id/network_connection'], # defined also in OSS
251
+
252
+ # only emulator
253
+ send_sms: [:post, 'session/:session_id/appium/device/send_sms'],
254
+ gsm_call: [:post, 'session/:session_id/appium/device/gsm_call'],
255
+ gsm_signal: [:post, 'session/:session_id/appium/device/gsm_signal'],
256
+ gsm_voice: [:post, 'session/:session_id/appium/device/gsm_voice'],
257
+ set_network_speed: [:post, 'session/:session_id/appium/device/network_speed'],
258
+ set_power_capacity: [:post, 'session/:session_id/appium/device/power_capacity'],
259
+ set_power_ac: [:post, 'session/:session_id/appium/device/power_ac'],
260
+
261
+ # For chromium: https://chromium.googlesource.com/chromium/src/+/master/chrome/test/chromedriver/server/http_handler.cc
262
+ chrome_send_command: [:post, 'session/:session_id/goog/cdp/execute']
263
+ }.freeze
264
+
265
+ COMMAND_IOS = {
266
+ touch_id: [:post, 'session/:session_id/appium/simulator/touch_id'],
267
+ toggle_touch_id_enrollment: [:post, 'session/:session_id/appium/simulator/toggle_touch_id_enrollment']
268
+ }.freeze
269
+
270
+ COMMANDS = {}.merge(COMMAND).merge(COMMAND_ANDROID).merge(COMMAND_IOS).freeze
271
+ end # module Commands
272
+ end # module Core
273
+ end # module Appium
@@ -18,10 +18,16 @@ module Appium
18
18
  module Device
19
19
  module AppManagement
20
20
  def launch_app
21
+ ::Appium::Logger.warn(
22
+ '[DEPRECATION] launch_app is deprecated. Please use activate_app instead.'
23
+ )
21
24
  execute :launch_app
22
25
  end
23
26
 
24
27
  def close_app
28
+ ::Appium::Logger.warn(
29
+ '[DEPRECATION] close_app is deprecated. Please use terminate_app instead.'
30
+ )
25
31
  execute :close_app
26
32
  end
27
33
 
@@ -39,21 +45,9 @@ module Appium
39
45
  raise NotImplementedError
40
46
  end
41
47
 
42
- def install_app(path,
43
- replace: nil,
44
- timeout: nil,
45
- allow_test_packages: nil,
46
- use_sdcard: nil,
47
- grant_permissions: nil)
48
+ def install_app(path, options = {})
48
49
  args = { appPath: path }
49
-
50
- args[:options] = {} if options?(replace, timeout, allow_test_packages, use_sdcard, grant_permissions)
51
-
52
- args[:options][:replace] = replace unless replace.nil?
53
- args[:options][:timeout] = timeout unless timeout.nil?
54
- args[:options][:allowTestPackages] = allow_test_packages unless allow_test_packages.nil?
55
- args[:options][:useSdcard] = use_sdcard unless use_sdcard.nil?
56
- args[:options][:grantPermissions] = grant_permissions unless grant_permissions.nil?
50
+ args[:options] = options unless options.empty?
57
51
 
58
52
  execute :install_app, {}, args
59
53
  end
@@ -47,7 +47,7 @@ module Appium
47
47
  # not available in the default OpenCV installation and have to be enabled manually
48
48
  # before library compilation. The default detector name is 'ORB'.
49
49
  # @param [String] match_func The name of the matching function. The default one is 'BruteForce'.
50
- # @param [String] good_matches_factor The maximum count of "good" matches (e. g. with minimal distances).
50
+ # @param [String, nil] good_matches_factor The maximum count of "good" matches (e. g. with minimal distances).
51
51
  # The default one is nil.
52
52
  # @param [Bool] visualize Makes the endpoint to return an image, which contains the visualized result of
53
53
  # the corresponding picture matching operation. This option is disabled by default.
@@ -94,7 +94,12 @@ module Appium
94
94
  # are supported.
95
95
  # @param [Bool] visualize Makes the endpoint to return an image, which contains the visualized result of
96
96
  # the corresponding picture matching operation. This option is disabled by default.
97
- # @param [Float] threshold [0.5] At what normalized threshold to reject
97
+ # @param [Float, nil] threshold [0.5] At what normalized threshold to reject
98
+ # @param [bool, nil] multiple Whether to enable the support of multiple image occurrences @since Appium 1.21.0.
99
+ # @param [integer, nil] match_neighbour_threshold The pixel distance between matches we consider to be part of
100
+ # the same template match @since Appium 1.21.0.
101
+ # This option is only considered if multiple matches mode is enabled.
102
+ # 10 pixels by default.
98
103
  #
99
104
  # @example
100
105
  # @driver.find_image_occurrence full_image: "image data 1", partial_image: "image data 2"
@@ -102,12 +107,15 @@ module Appium
102
107
  # visual = @@driver.find_image_occurrence full_image: image1, partial_image: image2, visualize: true
103
108
  # File.write 'find_result_visual.png', Base64.decode64(visual['visualization']) # if the image is PNG
104
109
  #
105
- def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil)
110
+ def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil,
111
+ multiple: nil, match_neighbour_threshold: nil)
106
112
  raise "visualize should be #{MATCH_TEMPLATE[:visualize]}" unless MATCH_TEMPLATE[:visualize].member?(visualize)
107
113
 
108
114
  options = {}
109
115
  options[:visualize] = visualize
110
116
  options[:threshold] = threshold unless threshold.nil?
117
+ options[:multiple] = multiple unless multiple.nil?
118
+ options[:matchNeighbourThreshold] = match_neighbour_threshold unless match_neighbour_threshold.nil?
111
119
 
112
120
  compare_images(mode: :matchTemplate, first_image: full_image, second_image: partial_image, options: options)
113
121
  end
@@ -144,7 +152,7 @@ module Appium
144
152
  # +:matchFeatures is by default.
145
153
  # @param [String] first_image An image data. All image formats, that OpenCV library itself accepts, are supported.
146
154
  # @param [String] second_image An image data. All image formats, that OpenCV library itself accepts, are supported.
147
- # @param [Hash] options The content of this dictionary depends on the actual +mode+ value.
155
+ # @param [Hash, nil] options The content of this dictionary depends on the actual +mode+ value.
148
156
  # See the documentation on +appium-support+ module for more details.
149
157
  # @return [Hash] The content of the resulting dictionary depends on the actual +mode+ and +options+ values.
150
158
  # See the documentation on +appium-support+ module for more details.
@@ -25,8 +25,8 @@ module Appium
25
25
  end
26
26
 
27
27
  def press_keycode(key, metastate: [], flags: [])
28
- raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
29
- raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
28
+ raise ::Appium::Core::Error::ArgumentError, 'flags should be Array' unless flags.is_a? Array
29
+ raise ::Appium::Core::Error::ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
30
30
 
31
31
  args = { keycode: key }
32
32
  args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
@@ -36,8 +36,8 @@ module Appium
36
36
  end
37
37
 
38
38
  def long_press_keycode(key, metastate: [], flags: [])
39
- raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
40
- raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
39
+ raise ::Appium::Core::Error::ArgumentError, 'flags should be Array' unless flags.is_a? Array
40
+ raise ::Appium::Core::Error::ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
41
41
 
42
42
  args = { keycode: key }
43
43
  args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
@@ -14,15 +14,18 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- module Commands
18
- module MJSONWP
19
- COMMANDS = ::Appium::Core::Commands::COMMANDS.merge(::Appium::Core::Base::Commands::OSS).merge(
20
- {
21
- # W3C already has.
22
- take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot']
23
- }
24
- ).freeze
25
- end # module MJSONWP
26
- end # module Commands
17
+ class Base
18
+ module Device
19
+ module Orientation
20
+ def screen_orientation=(orientation)
21
+ execute :set_screen_orientation, {}, { orientation: orientation }
22
+ end
23
+
24
+ def screen_orientation
25
+ execute :get_screen_orientation
26
+ end
27
+ end # module Orientation
28
+ end # module Device
29
+ end # class Base
27
30
  end # module Core
28
- end # Appium
31
+ end # module Appium
@@ -20,11 +20,13 @@ module Appium
20
20
  class Base
21
21
  module Device
22
22
  module TouchActions
23
+ # @deprecated Use W3C actions instead
23
24
  def touch_actions(actions)
24
25
  actions = { actions: [actions].flatten }
25
26
  execute :touch_actions, {}, actions
26
27
  end
27
28
 
29
+ # @deprecated Use W3C actions instead
28
30
  def multi_touch(actions)
29
31
  execute :multi_touch, {}, actions: actions
30
32
  end
@@ -17,12 +17,12 @@ module Appium
17
17
  class Base
18
18
  module Device
19
19
  module Value
20
- def set_immediate_value(element, *value)
21
- execute :set_immediate_value, { id: element.ref }, generate_value_and_text(value)
20
+ def set_immediate_value(element_id, *value)
21
+ execute :set_immediate_value, { id: element_id }, generate_value_and_text(value)
22
22
  end
23
23
 
24
- def replace_value(element, *value)
25
- execute :replace_value, { id: element.ref }, generate_value_and_text(value)
24
+ def replace_value(element_id, *value)
25
+ execute :replace_value, { id: element_id }, generate_value_and_text(value)
26
26
  end
27
27
 
28
28
  private
@@ -39,11 +39,9 @@ module Appium
39
39
  end
40
40
 
41
41
  # Keep .split(//) for backward compatibility for now
42
- text = keys.join('')
42
+ text = keys.join
43
43
 
44
- # FIXME: further work for W3C. Over appium 1.15.0 or later
45
- # { value: text.split(//), text: text }
46
- { value: text.split(//) }
44
+ { text: text }
47
45
  end
48
46
  end # module Value
49
47
  end # module Device
@@ -17,18 +17,17 @@ module Appium
17
17
  module Error
18
18
  class CoreError < StandardError; end
19
19
 
20
- # Capability related errors
21
- class NoCapabilityError < CoreError; end
22
- class CapabilityStructureError < CoreError; end
23
-
24
20
  # Appium related errors
25
21
  class NotSupportedAppiumServer < CoreError; end
26
22
  class NoSuchElementError < CoreError; end
27
23
 
28
24
  class UnsupportedOperationError < CoreError; end
29
25
 
30
- # Server side error
26
+ # Server side errors
31
27
  class ServerError < CoreError; end
28
+
29
+ # ruby_lib_core library specific errors
30
+ class ArgumentError < CoreError; end
32
31
  end
33
32
  end
34
33
  end
@@ -65,7 +65,10 @@ module Appium
65
65
  end
66
66
 
67
67
  def event=(log_event)
68
- raise ArgumentError('log_event should be Hash like { vendor: "appium", event: "funEvent"}') unless log_event.is_a?(Hash)
68
+ unless log_event.is_a?(Hash)
69
+ raise ::Appium::Core::Error::ArgumentError,
70
+ 'log_event should be Hash like { vendor: "appium", event: "funEvent"}'
71
+ end
69
72
 
70
73
  event vendor: log_event[:vendor], event: log_event[:event]
71
74
  end
@@ -14,6 +14,9 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
+ #
18
+ # @deprecated Use W3C actions instead
19
+ #
17
20
  # MultiTouch actions allow for multiple touches to happen at the same time,
18
21
  # for instance, to simulate multiple finger swipes.
19
22
  #
@@ -21,6 +24,18 @@ module Appium
21
24
  # add to a new MultiTouch action. When ready, call +prepare()+ and all
22
25
  # actions will be executed simultaneously.
23
26
  #
27
+ # Consider to use W3C spec touch action like the followings.
28
+ # https://www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html
29
+ # https://github.com/appium/ruby_lib_core/blob/master/test/functional/android/webdriver/w3c_actions_test.rb
30
+ # https://github.com/appium/ruby_lib_core/blob/master/test/functional/ios/webdriver/w3c_actions_test.rb
31
+ #
32
+ # About W3C actions
33
+ # https://www.youtube.com/watch?v=oAJ7jwMNFVU
34
+ # https://appiumpro.com/editions/30-ios-specific-touch-action-methods
35
+ # https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api
36
+ #
37
+ # Functional test code in ruby_lib_core repository also helps.
38
+ #
24
39
  # @example
25
40
  #
26
41
  # @driver = Appium::Core.for(opts).start_driver
@@ -36,6 +51,10 @@ module Appium
36
51
  attr_reader :driver
37
52
 
38
53
  def initialize(driver)
54
+ ::Appium::Logger.warn(
55
+ '[DEPRECATION] Appium::Core::MultiTouch is deprecated in W3C spec. Use W3C actions instead'
56
+ )
57
+
39
58
  @actions = []
40
59
  @driver = driver
41
60
  end
@@ -14,16 +14,26 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
+ #
18
+ # @deprecated Use W3C actions instead
19
+ #
17
20
  # Perform a series of gestures, one after another. Gestures are chained
18
21
  # together and only performed when +perform()+ is called. Default is conducted by global driver.
19
22
  #
20
23
  # Each method returns the object itself, so calls can be chained.
21
24
  #
22
25
  # Consider to use W3C spec touch action like the followings.
23
- # https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
26
+ # https://www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html
24
27
  # https://github.com/appium/ruby_lib_core/blob/master/test/functional/android/webdriver/w3c_actions_test.rb
25
28
  # https://github.com/appium/ruby_lib_core/blob/master/test/functional/ios/webdriver/w3c_actions_test.rb
26
29
  #
30
+ # About W3C actions
31
+ # https://www.youtube.com/watch?v=oAJ7jwMNFVU
32
+ # https://appiumpro.com/editions/30-ios-specific-touch-action-methods
33
+ # https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api
34
+ #
35
+ # Functional test code in ruby_lib_core repository also helps.
36
+ #
27
37
  # @example
28
38
  #
29
39
  # @driver = Appium::Core.for(opts).start_driver
@@ -39,6 +49,10 @@ module Appium
39
49
  attr_reader :actions, :driver
40
50
 
41
51
  def initialize(driver)
52
+ ::Appium::Logger.warn(
53
+ '[DEPRECATION] Appium::Core::TouchAction is deprecated in W3C spec. Use W3C actions instead'
54
+ )
55
+
42
56
  @actions = []
43
57
  @driver = driver
44
58
  end
@@ -195,7 +209,7 @@ module Appium
195
209
  end
196
210
 
197
211
  def args_with_ele_ref(args)
198
- args[:element] = args[:element].ref if args.key? :element
212
+ args[:element] = args[:element].id if args.key? :element
199
213
  args
200
214
  end
201
215
  end # class TouchAction