appium_lib_core 4.1.0 → 9.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +357 -270
- data/README.md +68 -16
- data/Rakefile +8 -20
- data/Steepfile +11 -0
- data/appium_lib_core.gemspec +13 -15
- data/bin/console +0 -4
- data/lib/appium_lib_core/android/device/auth_finger_print.rb +4 -1
- data/lib/appium_lib_core/android/device/clipboard.rb +4 -2
- data/lib/appium_lib_core/android/device/emulator.rb +11 -5
- data/lib/appium_lib_core/android/device/network.rb +10 -0
- data/lib/appium_lib_core/android/device/performance.rb +3 -0
- data/lib/appium_lib_core/android/device/screen.rb +5 -1
- data/lib/appium_lib_core/android/device.rb +83 -20
- data/lib/appium_lib_core/common/base/bridge.rb +238 -95
- data/lib/appium_lib_core/common/base/capabilities.rb +21 -8
- data/lib/appium_lib_core/common/{command/mjsonwp.rb → base/device_ime.rb} +33 -12
- data/lib/appium_lib_core/common/base/driver.rb +260 -334
- data/lib/appium_lib_core/common/base/driver_settings.rb +51 -0
- data/lib/appium_lib_core/common/base/has_location.rb +80 -0
- data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
- data/lib/appium_lib_core/common/base/http_default.rb +22 -38
- data/lib/appium_lib_core/{ios/uiautomation/bridge.rb → common/base/remote_status.rb} +9 -8
- data/lib/appium_lib_core/common/base/rotable.rb +62 -0
- data/lib/appium_lib_core/common/base/screenshot.rb +10 -10
- data/lib/appium_lib_core/common/base/search_context.rb +98 -172
- data/lib/appium_lib_core/common/base.rb +1 -5
- data/lib/appium_lib_core/common/command.rb +244 -4
- data/lib/appium_lib_core/common/device/app_management.rb +2 -26
- data/lib/appium_lib_core/common/device/context.rb +1 -5
- data/lib/appium_lib_core/common/device/image_comparison.rb +27 -10
- data/lib/appium_lib_core/common/device/keyevent.rb +4 -4
- data/lib/appium_lib_core/common/device/{touch_actions.rb → orientation.rb} +6 -10
- data/lib/appium_lib_core/common/device/screen_record.rb +8 -2
- data/lib/appium_lib_core/common/error.rb +5 -5
- data/lib/appium_lib_core/common/log.rb +5 -4
- data/lib/appium_lib_core/common/wait.rb +38 -6
- data/lib/appium_lib_core/device.rb +3 -9
- data/lib/appium_lib_core/driver.rb +193 -182
- data/lib/appium_lib_core/{patch.rb → element.rb} +64 -26
- data/lib/appium_lib_core/ios/device/clipboard.rb +4 -2
- data/lib/appium_lib_core/ios/xcuitest/device.rb +2 -0
- data/lib/appium_lib_core/{common/base/command.rb → mac2/bridge.rb} +9 -8
- data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
- data/lib/appium_lib_core/mac2/device.rb +92 -0
- data/lib/appium_lib_core/{ios.rb → mac2.rb} +2 -5
- data/lib/appium_lib_core/support/event_firing_bridge.rb +57 -0
- data/lib/appium_lib_core/version.rb +2 -2
- data/lib/appium_lib_core.rb +23 -10
- data/rbs_collection.lock.yaml +252 -0
- data/rbs_collection.yaml +15 -0
- data/sig/gems/selenium/abstract_event_listener.rbs +8 -0
- data/sig/gems/selenium/capabilities.rbs +8 -0
- data/sig/gems/selenium/common.rbs +10 -0
- data/sig/gems/selenium/default.rbs +10 -0
- data/sig/gems/selenium/driver.rbs +7 -0
- data/sig/gems/selenium/has_session_id.rbs +8 -0
- data/sig/gems/selenium/has_web_storage.rbs +8 -0
- data/sig/gems/selenium/uploads_files.rbs +8 -0
- data/sig/lib/appium_lib_core/common/base/capabilities.rbs +9 -0
- data/sig/lib/appium_lib_core/common/base/driver.rbs +167 -0
- data/sig/lib/appium_lib_core/common/base/driver_settings.rbs +15 -0
- data/sig/lib/appium_lib_core/common/base/has_location.rbs +13 -0
- data/sig/lib/appium_lib_core/common/base/has_network_connection.rbs +19 -0
- data/sig/lib/appium_lib_core/common/base/http_default.rbs +38 -0
- data/sig/lib/appium_lib_core/common/base/platform.rbs +7 -0
- data/sig/lib/appium_lib_core/common/base/remote_status.rbs +9 -0
- data/sig/lib/appium_lib_core/common/base/rotable.rbs +17 -0
- data/sig/lib/appium_lib_core/common/base/screenshot.rbs +19 -0
- data/sig/lib/appium_lib_core/common/device/battery_status.rbs +13 -0
- data/sig/lib/appium_lib_core/common/wait.rbs +31 -0
- data/sig/lib/appium_lib_core/device.rbs +21 -0
- data/sig/lib/appium_lib_core/driver.rbs +196 -0
- data/sig/lib/appium_lib_core/ios/xcuitest/device/battery.rbs +15 -0
- data/sig/lib/appium_lib_core/version.rbs +7 -0
- data/sig/lib/appium_lib_core.rbs +8 -0
- metadata +88 -111
- data/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
- data/.github/contributing.md +0 -26
- data/.github/issue_template.md +0 -20
- data/.github/workflows/unittest.yml +0 -68
- data/.gitignore +0 -18
- data/.rubocop.yml +0 -58
- data/azure-pipelines.yml +0 -15
- data/ci-jobs/functional/android_setup.yml +0 -3
- data/ci-jobs/functional/ios_setup.yml +0 -7
- data/ci-jobs/functional/publish_test_result.yml +0 -18
- data/ci-jobs/functional/run_appium.yml +0 -25
- data/ci-jobs/functional/start-emulator.sh +0 -26
- data/ci-jobs/functional_test.yml +0 -298
- data/docs/mobile_command.md +0 -34
- data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -81
- data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -252
- data/lib/appium_lib_core/common/command/common.rb +0 -110
- data/lib/appium_lib_core/common/command/w3c.rb +0 -56
- data/lib/appium_lib_core/common/device/value.rb +0 -52
- data/lib/appium_lib_core/common/touch_action/multi_touch.rb +0 -56
- data/lib/appium_lib_core/common/touch_action/touch_actions.rb +0 -203
- data/lib/appium_lib_core/ios/uiautomation/device.rb +0 -44
- data/lib/appium_lib_core/ios/uiautomation/patch.rb +0 -34
- data/release_notes.md +0 -816
- data/script/commands.rb +0 -200
@@ -12,14 +12,23 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# rubocop:disable Style/ClassAndModuleChildren
|
16
15
|
module Appium
|
17
16
|
module Core
|
18
17
|
# Implement useful features for element.
|
19
18
|
# Patch for Selenium Webdriver.
|
20
|
-
class Selenium::WebDriver::Element
|
21
|
-
|
22
|
-
|
19
|
+
class Element < ::Selenium::WebDriver::Element
|
20
|
+
include ::Appium::Core::Base::TakesScreenshot
|
21
|
+
|
22
|
+
::Selenium::WebDriver::SearchContext.extra_finders = APPIUM_EXTRA_FINDERS
|
23
|
+
|
24
|
+
# Retuns the element id.
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
# @example
|
28
|
+
# e = @driver.find_element :accessibility_id, 'something'
|
29
|
+
# e.id
|
30
|
+
#
|
31
|
+
attr_reader :id
|
23
32
|
|
24
33
|
# Returns the value of attributes like below. Read each platform to know more details.
|
25
34
|
#
|
@@ -56,26 +65,6 @@ module Appium
|
|
56
65
|
# Alias for type
|
57
66
|
alias type send_keys
|
58
67
|
|
59
|
-
# Set the value to element directly
|
60
|
-
#
|
61
|
-
# @example
|
62
|
-
#
|
63
|
-
# @driver.immediate_value 'hello'
|
64
|
-
#
|
65
|
-
def immediate_value(*value)
|
66
|
-
@bridge.set_immediate_value(self, *value)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Replace the value to element directly
|
70
|
-
#
|
71
|
-
# @example
|
72
|
-
#
|
73
|
-
# @driver.replace_value 'hello'
|
74
|
-
#
|
75
|
-
def replace_value(*value)
|
76
|
-
@bridge.replace_value(self, *value)
|
77
|
-
end
|
78
|
-
|
79
68
|
# For use with location_rel.
|
80
69
|
#
|
81
70
|
# @return [::Selenium::WebDriver::Point] the relative x, y in a struct. ex: { x: 0.50, y: 0.20 }
|
@@ -99,7 +88,56 @@ module Appium
|
|
99
88
|
w = driver.window_size
|
100
89
|
::Selenium::WebDriver::Point.new "#{center_x} / #{w.width.to_f}", "#{center_y} / #{w.height.to_f}"
|
101
90
|
end
|
102
|
-
|
91
|
+
|
92
|
+
# Return an element screenshot as base64
|
93
|
+
#
|
94
|
+
# @return String Base 64 encoded string
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
#
|
98
|
+
# element.screenshot #=> "iVBORw0KGgoAAAANSUhEUgAABDgAAAB+CAIAAABOPDa6AAAAAX"
|
99
|
+
#
|
100
|
+
def screenshot
|
101
|
+
bridge.element_screenshot @id
|
102
|
+
end
|
103
|
+
|
104
|
+
# Return an element screenshot in the given format
|
105
|
+
#
|
106
|
+
# @param [:base64, :png] format
|
107
|
+
# @return String screenshot
|
108
|
+
#
|
109
|
+
# @example
|
110
|
+
#
|
111
|
+
# element.screenshot_as :base64 #=> "iVBORw0KGgoAAAANSUhEUgAABDgAAAB+CAIAAABOPDa6AAAAAX"
|
112
|
+
#
|
113
|
+
def screenshot_as(format)
|
114
|
+
case format
|
115
|
+
when :base64
|
116
|
+
bridge.element_screenshot @id
|
117
|
+
when :png
|
118
|
+
bridge.element_screenshot(@id).unpack('m')[0]
|
119
|
+
else
|
120
|
+
raise ::Appium::Core::Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Save an element screenshot to the given path
|
125
|
+
#
|
126
|
+
# @param [String] png_path A path to save the screenshot
|
127
|
+
# @return [File] Path to the element screenshot.
|
128
|
+
#
|
129
|
+
# @example
|
130
|
+
#
|
131
|
+
# element.save_screenshot("fine_name.png")
|
132
|
+
#
|
133
|
+
def save_screenshot(png_path)
|
134
|
+
extension = File.extname(png_path).downcase
|
135
|
+
if extension != '.png'
|
136
|
+
::Appium::Logger.warn 'name used for saved screenshot does not match file type. ' \
|
137
|
+
'It should end with .png extension'
|
138
|
+
end
|
139
|
+
File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
|
140
|
+
end
|
141
|
+
end # class Element
|
103
142
|
end # module Core
|
104
143
|
end # module Appium
|
105
|
-
# rubocop:enable Style/ClassAndModuleChildren
|
@@ -23,7 +23,8 @@ module Appium
|
|
23
23
|
::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
|
24
24
|
def get_clipboard(content_type: :plaintext)
|
25
25
|
unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
|
26
|
-
raise
|
26
|
+
raise ::Appium::Core::Error::ArgumentError,
|
27
|
+
"content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
|
27
28
|
end
|
28
29
|
|
29
30
|
params = { contentType: content_type }
|
@@ -36,7 +37,8 @@ module Appium
|
|
36
37
|
::Appium::Core::Device.add_endpoint_method(:set_clipboard) do
|
37
38
|
def set_clipboard(content:, content_type: :plaintext)
|
38
39
|
unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
|
39
|
-
raise
|
40
|
+
raise ::Appium::Core::Error::ArgumentError,
|
41
|
+
"content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
|
40
42
|
end
|
41
43
|
|
42
44
|
params = {
|
@@ -25,6 +25,7 @@ module Appium
|
|
25
25
|
|
26
26
|
# rubocop:disable Layout/LineLength
|
27
27
|
|
28
|
+
# @deprecated Use 'mobile: hideKeyboard' extension instead.
|
28
29
|
# @!method hide_keyboard(close_key = nil, strategy = nil)
|
29
30
|
# Hide the onscreen keyboard
|
30
31
|
# @param [String] close_key The name of the key which closes the keyboard.
|
@@ -38,6 +39,7 @@ module Appium
|
|
38
39
|
# @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
|
39
40
|
#
|
40
41
|
|
42
|
+
# @deprecated Use 'mobile: backgroundApp' extension instead.
|
41
43
|
# @!method background_app(duration = 0)
|
42
44
|
# Backgrounds the app for a set number of seconds.
|
43
45
|
# This is a blocking application.
|
@@ -14,11 +14,12 @@
|
|
14
14
|
|
15
15
|
module Appium
|
16
16
|
module Core
|
17
|
-
|
18
|
-
module
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
17
|
+
module Mac2
|
18
|
+
module Bridge
|
19
|
+
def self.for(target)
|
20
|
+
target.extend Appium::Core::Mac2::Device
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Appium
|
16
|
+
module Core
|
17
|
+
module Mac2
|
18
|
+
module Device
|
19
|
+
module Screen
|
20
|
+
def self.add_methods
|
21
|
+
::Appium::Core::Device.add_endpoint_method(:start_recording_screen) do
|
22
|
+
def start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT',
|
23
|
+
file_field_name: nil, form_fields: nil, headers: nil, force_restart: nil,
|
24
|
+
fps: nil, preset: nil, video_filter: nil, time_limit: nil,
|
25
|
+
enable_capture_clicks: nil, enable_cursor_capture: nil, device_id: nil)
|
26
|
+
option = ::Appium::Core::Base::Device::ScreenRecord.new(
|
27
|
+
remote_path: remote_path, user: user, pass: pass, method: method,
|
28
|
+
file_field_name: file_field_name, form_fields: form_fields, headers: headers,
|
29
|
+
force_restart: force_restart
|
30
|
+
).upload_option
|
31
|
+
|
32
|
+
option[:fps] = fps unless fps.nil?
|
33
|
+
option[:preset] = preset unless preset.nil?
|
34
|
+
option[:videoFilter] = video_filter unless video_filter.nil?
|
35
|
+
option[:captureClicks] = enable_capture_clicks unless enable_capture_clicks.nil?
|
36
|
+
option[:captureCursor] = enable_cursor_capture unless enable_cursor_capture.nil?
|
37
|
+
option[:deviceId] = device_id unless device_id.nil?
|
38
|
+
option[:timeLimit] = time_limit unless time_limit.nil?
|
39
|
+
|
40
|
+
execute(:start_recording_screen, {}, { options: option })
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end # module Screen
|
45
|
+
end # module Device
|
46
|
+
end # module Mac2
|
47
|
+
end # module Core
|
48
|
+
end # module Appium
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative 'device/screen'
|
16
|
+
|
17
|
+
module Appium
|
18
|
+
module Core
|
19
|
+
module Mac2
|
20
|
+
module Device
|
21
|
+
extend Forwardable
|
22
|
+
|
23
|
+
# rubocop:disable Layout/LineLength
|
24
|
+
|
25
|
+
# @since Appium 1.20.0
|
26
|
+
# @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', file_field_name: nil, form_fields: nil, headers: nil, force_restart: nil, fps: nil, preset: nil, video_filter: nil, enable_capture_clicks: nil, enable_cursor_capture: nil, device_id: nil)
|
27
|
+
#
|
28
|
+
# Record the display of devices running iOS Simulator since Xcode 9 or real devices since iOS 11
|
29
|
+
# (ffmpeg utility is required: 'brew install ffmpeg').
|
30
|
+
# We would recommend to play the video by VLC or Mplayer if you can not play the video with other video players.
|
31
|
+
#
|
32
|
+
# @param [String] remote_path The path to the remote location, where the resulting video should be uploaded.
|
33
|
+
# The following protocols are supported: http/https, ftp.
|
34
|
+
# Null or empty string value (the default setting) means the content of resulting
|
35
|
+
# file should be encoded as Base64 and passed as the endpount response value.
|
36
|
+
# An exception will be thrown if the generated media file is too big to
|
37
|
+
# fit into the available process memory.
|
38
|
+
# This option only has an effect if there is screen recording process in progreess
|
39
|
+
# and +forceRestart+ parameter is not set to +true+.
|
40
|
+
# @param [String] user The name of the user for the remote authentication.
|
41
|
+
# @param [String] pass The password for the remote authentication.
|
42
|
+
# @param [String] method The http multipart upload method name. The 'PUT' one is used by default.
|
43
|
+
# @param [String] file_field_name The name of the form field containing the binary payload in multipart/form-data
|
44
|
+
# requests since Appium 1.18.0. Defaults to 'file'.
|
45
|
+
# @param [Array<Hash, Array<String>>] form_fields The form fields mapping in multipart/form-data requests since Appium 1.18.0.
|
46
|
+
# If any entry has the same key in this mapping, then it is going to be ignored.
|
47
|
+
# @param [Hash] headers The additional headers in multipart/form-data requests since Appium 1.18.0.
|
48
|
+
# @param [Boolean] force_restart Whether to try to catch and upload/return the currently running screen recording
|
49
|
+
# (+false+, the default setting on server) or ignore the result of it
|
50
|
+
# and start a new recording immediately (+true+).
|
51
|
+
# @param [integer] fps The count of frames per second in the resulting video.
|
52
|
+
# Increasing fps value also increases the size of the resulting video file and the CPU usage.
|
53
|
+
# The default value is 15.
|
54
|
+
# @param [String] preset A preset is a collection of options that will provide a certain encoding speed to compression ratio.
|
55
|
+
# A slower preset will provide better compression (compression is quality per filesize).
|
56
|
+
# This means that, for example, if you target a certain file size or constant bit rate, you will
|
57
|
+
# achieve better quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264
|
58
|
+
# for more details.
|
59
|
+
# @param [Boolean] enable_cursor_capture Whether to capture the click gestures while recording the screen. Disabled by default.
|
60
|
+
# @param [Boolean] enable_capture_clicks Recording time. 180 seconds is by default.
|
61
|
+
# @param [String] video_filter The video filter spec to apply for ffmpeg.
|
62
|
+
# See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values.
|
63
|
+
# Example: Set it to +scale=ifnot(gte(iw\,1024)\,iw\,1024):-2+ in order to limit the video width
|
64
|
+
# to 1024px. The height will be adjusted automatically to match the actual screen aspect ratio.
|
65
|
+
# @param [integer] device_id Screen device index to use for the recording.
|
66
|
+
# The list of available devices could be retrieved using
|
67
|
+
# +ffmpeg -f avfoundation -list_devices true -i ""+ command.
|
68
|
+
# This option is mandatory and must be always provided.
|
69
|
+
# @param [String] time_limit The maximum recording time. The default value is 600 seconds (10 minutes).
|
70
|
+
# The minimum time resolution unit is one second.
|
71
|
+
#
|
72
|
+
# @example
|
73
|
+
#
|
74
|
+
# @driver.start_recording_screen
|
75
|
+
# @driver.start_recording_screen fps: 30, enable_cursor_capture: true
|
76
|
+
#
|
77
|
+
|
78
|
+
# rubocop:enable Layout/LineLength
|
79
|
+
|
80
|
+
####
|
81
|
+
## class << self
|
82
|
+
####
|
83
|
+
|
84
|
+
class << self
|
85
|
+
def extended(_mod)
|
86
|
+
Screen.add_methods
|
87
|
+
end
|
88
|
+
end # class << self
|
89
|
+
end # module Device
|
90
|
+
end # module Mac2
|
91
|
+
end # module Core
|
92
|
+
end # module Appium
|
@@ -13,8 +13,5 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
# loaded in common/driver.rb
|
16
|
-
require_relative '
|
17
|
-
|
18
|
-
require_relative 'ios/uiautomation/patch'
|
19
|
-
require_relative 'ios/uiautomation/device'
|
20
|
-
require_relative 'ios/uiautomation/bridge'
|
16
|
+
require_relative 'mac2/device'
|
17
|
+
require_relative 'mac2/bridge'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Appium
|
16
|
+
module Support
|
17
|
+
class EventFiringBridge < ::Selenium::WebDriver::Support::EventFiringBridge
|
18
|
+
# This module inherits ::Selenium::WebDriver::Support::EventFiringBridge
|
19
|
+
# to provide customer listener availability.
|
20
|
+
# https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/support/event_firing_bridge.rb#L79
|
21
|
+
|
22
|
+
def initialize(delegate, listener, **opts)
|
23
|
+
@appium_options = opts
|
24
|
+
super delegate, listener
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_element_by(how, what, parent = nil)
|
28
|
+
e = dispatch(:find, how, what, driver) do
|
29
|
+
@delegate.find_element_by how, what, parent
|
30
|
+
end
|
31
|
+
|
32
|
+
::Appium::Core::Element.new self, e.ref.last
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_elements_by(how, what, parent = nil)
|
36
|
+
es = dispatch(:find, how, what, driver) do
|
37
|
+
@delegate.find_elements_by(how, what, parent)
|
38
|
+
end
|
39
|
+
|
40
|
+
es.map { |e| ::Appium::Core::Element.new self, e.ref.last }
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def create_element(ref)
|
46
|
+
::Appium::Core::Element.new @delegate, ref
|
47
|
+
end
|
48
|
+
|
49
|
+
def driver
|
50
|
+
# To not gives the listener
|
51
|
+
@appium_options.delete(:listener)
|
52
|
+
|
53
|
+
@driver ||= ::Appium::Core::Base::Driver.new(bridge: self, listener: nil, **@appium_options)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
module Appium
|
16
16
|
module Core
|
17
|
-
VERSION = '
|
18
|
-
DATE = '
|
17
|
+
VERSION = '9.3.0' unless defined? ::Appium::Core::VERSION
|
18
|
+
DATE = '2024-12-08' unless defined? ::Appium::Core::DATE
|
19
19
|
end
|
20
20
|
end
|
data/lib/appium_lib_core.rb
CHANGED
@@ -17,23 +17,32 @@ require 'selenium-webdriver'
|
|
17
17
|
require_relative 'appium_lib_core/version'
|
18
18
|
require_relative 'appium_lib_core/common'
|
19
19
|
require_relative 'appium_lib_core/driver'
|
20
|
-
|
21
20
|
require_relative 'appium_lib_core/device'
|
22
|
-
|
23
|
-
|
24
|
-
require_relative 'appium_lib_core/patch'
|
21
|
+
require_relative 'appium_lib_core/element'
|
22
|
+
require_relative 'appium_lib_core/support/event_firing_bridge'
|
25
23
|
|
26
24
|
module Appium
|
27
|
-
# convert
|
25
|
+
# convert the top level keys to symbols.
|
28
26
|
#
|
29
|
-
# based on deep_symbolize_keys & deep_transform_keys from rails
|
30
|
-
# https://github.com/rails/docrails/blob/a3b1105ada3da64acfa3843b164b14b734456a50/activesupport/lib/active_support/core_ext/hash/keys.rb#L84
|
31
27
|
# @param [Hash] hash Hash value to make symbolise
|
32
|
-
|
33
|
-
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# opts = Appium.symbolize_keys(opts)
|
31
|
+
#
|
32
|
+
def self.symbolize_keys(hash, nested: false, enable_deprecation_msg: true)
|
33
|
+
# FIXME: As https://github.com/appium/ruby_lib/issues/945, we must remove this implicit string to symbol.
|
34
|
+
# But appium_lib_core's some capability handling expect to be symbol, so we should test to remove
|
35
|
+
# the methods which expect the symbol first.
|
36
|
+
raise ::Appium::Core::Error::ArgumentError, 'symbolize_keys requires a hash' unless hash.is_a? Hash
|
34
37
|
|
35
38
|
hash.each_with_object({}) do |pair, acc|
|
36
39
|
key = begin
|
40
|
+
if enable_deprecation_msg && !(pair[0].is_a? Symbol)
|
41
|
+
::Appium::Logger.warn("[Deprecation] The key '#{pair[0]}' must be a symbol while currently it " \
|
42
|
+
"is #{pair[0].class.name}. Please define the key as a Symbol. " \
|
43
|
+
'Converting it to Symbol for now.')
|
44
|
+
end
|
45
|
+
|
37
46
|
pair[0].to_sym
|
38
47
|
rescue StandardError => e
|
39
48
|
::Appium::Logger.warn(e.message)
|
@@ -41,7 +50,11 @@ module Appium
|
|
41
50
|
end
|
42
51
|
|
43
52
|
value = pair[1]
|
44
|
-
acc[key] =
|
53
|
+
acc[key] = if nested
|
54
|
+
value.is_a?(Hash) ? symbolize_keys(value, nested: false, enable_deprecation_msg: false) : value
|
55
|
+
else
|
56
|
+
value
|
57
|
+
end
|
45
58
|
end
|
46
59
|
end
|
47
60
|
|