appium_lib_core 1.6.0 → 1.7.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +16 -0
- data/lib/appium_lib_core/android/device.rb +301 -406
- data/lib/appium_lib_core/android/device/clipboard.rb +42 -0
- data/lib/appium_lib_core/android/device/emulator.rb +149 -147
- data/lib/appium_lib_core/android/device/network.rb +47 -0
- data/lib/appium_lib_core/android/device/performance.rb +24 -0
- data/lib/appium_lib_core/android/device/screen.rb +39 -0
- data/lib/appium_lib_core/android/espresso/bridge.rb +1 -1
- data/lib/appium_lib_core/android/uiautomator1/bridge.rb +1 -1
- data/lib/appium_lib_core/android/uiautomator2/bridge.rb +1 -1
- data/lib/appium_lib_core/android/uiautomator2/device.rb +3 -14
- data/lib/appium_lib_core/android/uiautomator2/device/battery.rb +28 -0
- data/lib/appium_lib_core/common/base/http_default.rb +5 -1
- data/lib/appium_lib_core/device.rb +50 -370
- data/lib/appium_lib_core/device/app_management.rb +113 -0
- data/lib/appium_lib_core/device/app_state.rb +18 -1
- data/lib/appium_lib_core/device/context.rb +48 -0
- data/lib/appium_lib_core/device/device_lock.rb +28 -0
- data/lib/appium_lib_core/device/file_management.rb +32 -0
- data/lib/appium_lib_core/device/image_comparison.rb +1 -3
- data/lib/appium_lib_core/device/ime_actions.rb +43 -0
- data/lib/appium_lib_core/device/keyboard.rb +26 -0
- data/lib/appium_lib_core/device/keyevent.rb +44 -0
- data/lib/appium_lib_core/device/screen_record.rb +21 -0
- data/lib/appium_lib_core/device/setting.rb +21 -0
- data/lib/appium_lib_core/device/touch_actions.rb +22 -0
- data/lib/appium_lib_core/device/value.rb +23 -0
- data/lib/appium_lib_core/driver.rb +8 -0
- data/lib/appium_lib_core/ios/device.rb +70 -101
- data/lib/appium_lib_core/ios/device/clipboard.rb +41 -0
- data/lib/appium_lib_core/ios/uiautomation/bridge.rb +1 -1
- data/lib/appium_lib_core/ios/xcuitest/bridge.rb +2 -2
- data/lib/appium_lib_core/ios/xcuitest/device.rb +166 -227
- data/lib/appium_lib_core/ios/xcuitest/device/battery.rb +28 -0
- data/lib/appium_lib_core/ios/xcuitest/device/performance.rb +40 -0
- data/lib/appium_lib_core/ios/xcuitest/device/screen.rb +30 -0
- data/lib/appium_lib_core/version.rb +2 -2
- data/release_notes.md +12 -0
- metadata +21 -2
@@ -0,0 +1,23 @@
|
|
1
|
+
module Appium
|
2
|
+
module Core
|
3
|
+
module Device
|
4
|
+
module Value
|
5
|
+
def self.add_methods
|
6
|
+
::Appium::Core::Device.add_endpoint_method(:set_immediate_value) do
|
7
|
+
def set_immediate_value(element, *value)
|
8
|
+
keys = ::Selenium::WebDriver::Keys.encode(value)
|
9
|
+
execute :set_immediate_value, { id: element.ref }, value: Array(keys)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
::Appium::Core::Device.add_endpoint_method(:replace_value) do
|
14
|
+
def replace_value(element, *value)
|
15
|
+
keys = ::Selenium::WebDriver::Keys.encode(value)
|
16
|
+
execute :replace_value, { id: element.ref }, value: Array(keys)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end # module Value
|
21
|
+
end # module Device
|
22
|
+
end # module Core
|
23
|
+
end # module Appium
|
@@ -97,8 +97,16 @@ module Appium
|
|
97
97
|
new(target, opts)
|
98
98
|
end
|
99
99
|
|
100
|
+
# @private
|
101
|
+
# For testing purpose of delegate_from_appium_driver
|
102
|
+
private def delegated_target_for_test
|
103
|
+
@delegate_target
|
104
|
+
end
|
105
|
+
|
100
106
|
# @private
|
101
107
|
def initialize(target, opts = {})
|
108
|
+
@delegate_target = target # for testing purpose
|
109
|
+
|
102
110
|
opts = Appium.symbolize_keys opts
|
103
111
|
validate_keys(opts)
|
104
112
|
|
@@ -1,111 +1,80 @@
|
|
1
|
-
|
1
|
+
require_relative 'device/clipboard'
|
2
2
|
|
3
3
|
module Appium
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
::Appium::Core::Device.add_endpoint_method(:toggle_touch_id_enrollment) do
|
68
|
-
def toggle_touch_id_enrollment(enabled = true)
|
69
|
-
execute :toggle_touch_id_enrollment, {}, enabled: enabled
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
add_clipboard
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def add_clipboard
|
79
|
-
::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
|
80
|
-
def get_clipboard(content_type: :plaintext)
|
81
|
-
unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
|
82
|
-
raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
|
4
|
+
module Core
|
5
|
+
module Ios
|
6
|
+
module Device
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
# @!method touch_id(match = true)
|
10
|
+
# An instance method of Appium::Core::Device .
|
11
|
+
# Simulate Touch ID with either valid (match == true) or invalid (match == false) fingerprint.
|
12
|
+
# @param [Boolean] match fingerprint validity. Defaults to true.
|
13
|
+
# @return [String]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
#
|
17
|
+
# @driver.touch_id true #=> Simulate valid fingerprint
|
18
|
+
# @driver.touch_id false #=> Simulate invalid fingerprint
|
19
|
+
#
|
20
|
+
|
21
|
+
# @!method toggle_touch_id_enrollment(enabled = true)
|
22
|
+
# An instance method of Appium::Core::Device .
|
23
|
+
# Toggle touch id enrollment on an iOS Simulator.
|
24
|
+
# @param [Boolean] enabled Enable toggle touch id enrollment. Set true by default.
|
25
|
+
# @return [String]
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
#
|
29
|
+
# @driver.toggle_touch_id_enrollment #=> Enable toggle enrolled
|
30
|
+
# @driver.toggle_touch_id_enrollment true #=> Enable toggle enrolled
|
31
|
+
# @driver.toggle_touch_id_enrollment false #=> Disable toggle enrolled
|
32
|
+
#
|
33
|
+
|
34
|
+
# @!method get_clipboard(content_type: :plaintext)
|
35
|
+
# Set the content of device's clipboard.
|
36
|
+
# @param [String] content_type: one of supported content types.
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
#
|
41
|
+
# @driver.get_clipboard #=> "happy testing"
|
42
|
+
#
|
43
|
+
|
44
|
+
# @!method set_clipboard(content:, content_type: :plaintext)
|
45
|
+
# Set the content of device's clipboard.
|
46
|
+
# @param [String] content_type: one of supported content types.
|
47
|
+
# @param [String] content: Contents to be set. (Will encode with base64-encoded inside this method)
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
#
|
51
|
+
# @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"}
|
52
|
+
#
|
53
|
+
|
54
|
+
####
|
55
|
+
## class << self
|
56
|
+
####
|
57
|
+
|
58
|
+
class << self
|
59
|
+
def extended(_mod)
|
60
|
+
::Appium::Core::Device.extend_webdriver_with_forwardable
|
61
|
+
|
62
|
+
::Appium::Core::Device.add_endpoint_method(:touch_id) do
|
63
|
+
def touch_id(match = true)
|
64
|
+
execute :touch_id, {}, match: match
|
83
65
|
end
|
84
|
-
|
85
|
-
params = {}
|
86
|
-
params[:contentType] = content_type
|
87
|
-
|
88
|
-
data = execute(:get_clipboard, {}, params)
|
89
|
-
Base64.decode64 data
|
90
66
|
end
|
91
|
-
end
|
92
67
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
|
68
|
+
::Appium::Core::Device.add_endpoint_method(:toggle_touch_id_enrollment) do
|
69
|
+
def toggle_touch_id_enrollment(enabled = true)
|
70
|
+
execute :toggle_touch_id_enrollment, {}, enabled: enabled
|
97
71
|
end
|
98
|
-
|
99
|
-
params = {
|
100
|
-
contentType: content_type,
|
101
|
-
content: Base64.encode64(content)
|
102
|
-
}
|
103
|
-
|
104
|
-
execute(:set_clipboard, {}, params)
|
105
72
|
end
|
73
|
+
|
74
|
+
Clipboard.add_methods
|
106
75
|
end
|
107
76
|
end
|
108
|
-
end
|
109
|
-
end # module
|
110
|
-
end # module
|
77
|
+
end # module Device
|
78
|
+
end # module iOS
|
79
|
+
end # module Core
|
111
80
|
end # module Appium
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Appium
|
4
|
+
module Core
|
5
|
+
module Ios
|
6
|
+
module Device
|
7
|
+
module Clipboard
|
8
|
+
def self.add_methods
|
9
|
+
::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
|
10
|
+
def get_clipboard(content_type: :plaintext)
|
11
|
+
unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
|
12
|
+
raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
|
13
|
+
end
|
14
|
+
|
15
|
+
params = { contentType: content_type }
|
16
|
+
|
17
|
+
data = execute(:get_clipboard, {}, params)
|
18
|
+
Base64.decode64 data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
::Appium::Core::Device.add_endpoint_method(:set_clipboard) do
|
23
|
+
def set_clipboard(content:, content_type: :plaintext)
|
24
|
+
unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
|
25
|
+
raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
|
26
|
+
end
|
27
|
+
|
28
|
+
params = {
|
29
|
+
contentType: content_type,
|
30
|
+
content: Base64.encode64(content)
|
31
|
+
}
|
32
|
+
|
33
|
+
execute(:set_clipboard, {}, params)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end # module Clipboard
|
38
|
+
end # module Device
|
39
|
+
end # module Ios
|
40
|
+
end # module Core
|
41
|
+
end # module Appium
|
@@ -6,8 +6,8 @@ module Appium
|
|
6
6
|
def self.for(target)
|
7
7
|
Core::Ios::SearchContext.extend
|
8
8
|
Core::Ios::Xcuitest::SearchContext.extend
|
9
|
-
target.extend Appium::Ios::Device
|
10
|
-
target.extend Appium::Ios::Xcuitest::Device
|
9
|
+
target.extend Appium::Core::Ios::Device
|
10
|
+
target.extend Appium::Core::Ios::Xcuitest::Device
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,234 +1,173 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module Device
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
# rubocop:disable Metrics/LineLength
|
8
|
-
|
9
|
-
# @!method hide_keyboard(close_key = nil, strategy = nil)
|
10
|
-
# Hide the onscreen keyboard
|
11
|
-
# @param [String] close_key The name of the key which closes the keyboard.
|
12
|
-
# @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
|
13
|
-
# XCUITest ignore this argument.
|
14
|
-
# Default for iOS is `:pressKey`. Default for Android is `:tapOutside`.
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
#
|
18
|
-
# @driver.hide_keyboard # Close a keyboard with the 'Done' button
|
19
|
-
# @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
|
20
|
-
#
|
21
|
-
|
22
|
-
# @!method background_app(duration = 0)
|
23
|
-
# Backgrounds the app for a set number of seconds.
|
24
|
-
# This is a blocking application.
|
25
|
-
# @param [Integer] duration How many seconds to background the app for.
|
26
|
-
#
|
27
|
-
# @example
|
28
|
-
#
|
29
|
-
# @driver.background_app
|
30
|
-
# @driver.background_app(5)
|
31
|
-
# @driver.background_app(-1) #=> the app never come back. https://github.com/appium/appium/issues/7741
|
32
|
-
#
|
33
|
-
|
34
|
-
# @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: nil, force_restart: nil, video_type: 'mp4', time_limit: '180', video_quality: 'medium')
|
35
|
-
# @param [String] remote_path: The path to the remote location, where the resulting video should be uploaded.
|
36
|
-
# The following protocols are supported: http/https, ftp.
|
37
|
-
# Null or empty string value (the default setting) means the content of resulting
|
38
|
-
# file should be encoded as Base64 and passed as the endpount response value.
|
39
|
-
# An exception will be thrown if the generated media file is too big to
|
40
|
-
# fit into the available process memory.
|
41
|
-
# This option only has an effect if there is screen recording process in progreess
|
42
|
-
# and `forceRestart` parameter is not set to `true`.
|
43
|
-
# @param [String] user: The name of the user for the remote authentication.
|
44
|
-
# @param [String] pass: The password for the remote authentication.
|
45
|
-
# @param [String] method: The http multipart upload method name. The 'PUT' one is used by default.
|
46
|
-
# @param [Boolean] force_restart: Whether to try to catch and upload/return the currently running screen recording
|
47
|
-
# (`false`, the default setting on server) or ignore the result of it
|
48
|
-
# and start a new recording immediately (`true`).
|
49
|
-
# @param [String] video_type: The format of the screen capture to be recorded.
|
50
|
-
# Available formats: "h264", "mp4" or "fmp4". Default is "mp4".
|
51
|
-
# Only works for Simulator.
|
52
|
-
# @param [String] time_limit: Recording time. 180 seconds is by default.
|
53
|
-
# @param [String] video_quality: The video encoding quality (low, medium, high, photo - defaults to medium).
|
54
|
-
# Only works for real devices.
|
55
|
-
#
|
56
|
-
# @example
|
57
|
-
#
|
58
|
-
# @driver.start_recording_screen
|
59
|
-
# @driver.start_recording_screen video_type: 'h264', time_limit: '260'
|
60
|
-
#
|
61
|
-
|
62
|
-
# @since 1.3.4
|
63
|
-
# @!method start_performance_record(timeout: 300000, profile_name: 'Activity Monitor')
|
64
|
-
#
|
65
|
-
# This is a blocking application.
|
66
|
-
# @param [Integer|String] timeout: The maximum count of milliseconds to record the profiling information.
|
67
|
-
# @param [String] profile_name: The name of existing performance profile to apply.
|
68
|
-
# Execute `instruments -s` to show the list of available profiles.
|
69
|
-
# Note, that not all profiles are supported on mobile devices.
|
70
|
-
# @param [Integer|String] pid: The ID of the process to measure the performance for.
|
71
|
-
# Set it to `current` in order to measure the performance of
|
72
|
-
# the process, which belongs to the currently active application.
|
73
|
-
# All processes running on the device are measured if
|
74
|
-
# pid is unset (the default setting). Setting process ID while
|
75
|
-
# device under test is Simulator might require `instruments` to be launched
|
76
|
-
# with sudo privileges, which is not supported and will throw a timeout exception.
|
77
|
-
# @return nil
|
78
|
-
#
|
79
|
-
# @example
|
80
|
-
#
|
81
|
-
# @driver.start_performance_record # default: (timeout: 300000, profile_name: 'Activity Monitor')
|
82
|
-
# @driver.start_performance_record(timeout: 300000, profile_name: 'Activity Monitor')
|
83
|
-
#
|
84
|
-
|
85
|
-
# @since 1.3.4
|
86
|
-
# @!method get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor', remote_path: nil, user: nil, pass: nil, method: 'PUT')
|
87
|
-
#
|
88
|
-
# This is a blocking application.
|
89
|
-
#
|
90
|
-
# @param [String] save_file_path: A path to save data as zipped .trace file
|
91
|
-
# @param [String] profile_name: The name of existing performance profile to apply.
|
92
|
-
# Execute `instruments -s` to show the list of available profiles.
|
93
|
-
# Note, that not all profiles are supported on mobile devices.
|
94
|
-
# @param [String] save_file_path: The name of existing performance profile to apply.
|
95
|
-
# Execute `instruments -s` to show the list of available profiles.
|
96
|
-
# Note, that not all profiles are supported on mobile devices.
|
97
|
-
# @param [String] remote_path: The path to the remote location, where the resulting zipped .trace file should be uploaded.
|
98
|
-
# The following protocols are supported: http/https, ftp.
|
99
|
-
# Null or empty string value (the default setting) means the content of resulting
|
100
|
-
# file should be zipped, encoded as Base64 and passed as the endpount response value.
|
101
|
-
# An exception will be thrown if the generated file is too big to
|
102
|
-
# fit into the available process memory.
|
103
|
-
# @param [String] user: The name of the user for the remote authentication. Only works if `remotePath` is provided.
|
104
|
-
# @param [String] pass: The password for the remote authentication. Only works if `remotePath` is provided.
|
105
|
-
# @param [String] method: The http multipart upload method name. Only works if `remotePath` is provided.
|
106
|
-
#
|
107
|
-
# @example
|
108
|
-
#
|
109
|
-
# @driver.get_performance_record
|
110
|
-
# @driver.get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor')
|
111
|
-
|
112
|
-
# @since 1.6.0
|
113
|
-
# @!method battery_info
|
114
|
-
#
|
115
|
-
# Get battery information.
|
116
|
-
#
|
117
|
-
# @return [Hash] Return battery level and battery state from the target real device. (Simulator has no battery.)
|
118
|
-
# https://developer.apple.com/documentation/uikit/uidevice/ 's `batteryLevel` and `batteryState`.
|
119
|
-
# Battery level in range [0.0, 1.0], where 1.0 means 100% charge. -1 is returned
|
120
|
-
# if the actual value cannot be retrieved from the system.
|
121
|
-
# Battery state. The following symbols are possible
|
122
|
-
# `:unplugged, :charging, :full`
|
123
|
-
#
|
124
|
-
# @example
|
125
|
-
#
|
126
|
-
# @driver.battery_info #=> { state: :full, level: 0.7 }
|
127
|
-
#
|
128
|
-
|
129
|
-
# rubocop:enable Metrics/LineLength
|
1
|
+
require_relative 'device/performance'
|
2
|
+
require_relative 'device/screen'
|
3
|
+
require_relative 'device/battery'
|
130
4
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
5
|
+
module Appium
|
6
|
+
module Core
|
7
|
+
module Ios
|
8
|
+
module Xcuitest
|
9
|
+
module Device
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
# rubocop:disable Metrics/LineLength
|
13
|
+
|
14
|
+
# @!method hide_keyboard(close_key = nil, strategy = nil)
|
15
|
+
# Hide the onscreen keyboard
|
16
|
+
# @param [String] close_key The name of the key which closes the keyboard.
|
17
|
+
# @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
|
18
|
+
# XCUITest ignore this argument.
|
19
|
+
# Default for iOS is `:pressKey`. Default for Android is `:tapOutside`.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
#
|
23
|
+
# @driver.hide_keyboard # Close a keyboard with the 'Done' button
|
24
|
+
# @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
|
25
|
+
#
|
26
|
+
|
27
|
+
# @!method background_app(duration = 0)
|
28
|
+
# Backgrounds the app for a set number of seconds.
|
29
|
+
# This is a blocking application.
|
30
|
+
# @param [Integer] duration How many seconds to background the app for.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
#
|
34
|
+
# @driver.background_app
|
35
|
+
# @driver.background_app(5)
|
36
|
+
# @driver.background_app(-1) #=> the app never come back. https://github.com/appium/appium/issues/7741
|
37
|
+
#
|
38
|
+
|
39
|
+
# @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: nil, force_restart: nil, video_type: 'mp4', time_limit: '180', video_quality: 'medium')
|
40
|
+
# @param [String] remote_path: The path to the remote location, where the resulting video should be uploaded.
|
41
|
+
# The following protocols are supported: http/https, ftp.
|
42
|
+
# Null or empty string value (the default setting) means the content of resulting
|
43
|
+
# file should be encoded as Base64 and passed as the endpount response value.
|
44
|
+
# An exception will be thrown if the generated media file is too big to
|
45
|
+
# fit into the available process memory.
|
46
|
+
# This option only has an effect if there is screen recording process in progreess
|
47
|
+
# and `forceRestart` parameter is not set to `true`.
|
48
|
+
# @param [String] user: The name of the user for the remote authentication.
|
49
|
+
# @param [String] pass: The password for the remote authentication.
|
50
|
+
# @param [String] method: The http multipart upload method name. The 'PUT' one is used by default.
|
51
|
+
# @param [Boolean] force_restart: Whether to try to catch and upload/return the currently running screen recording
|
52
|
+
# (`false`, the default setting on server) or ignore the result of it
|
53
|
+
# and start a new recording immediately (`true`).
|
54
|
+
# @param [String] video_type: The format of the screen capture to be recorded.
|
55
|
+
# Available formats: "h264", "mp4" or "fmp4". Default is "mp4".
|
56
|
+
# Only works for Simulator.
|
57
|
+
# @param [String] time_limit: Recording time. 180 seconds is by default.
|
58
|
+
# @param [String] video_quality: The video encoding quality (low, medium, high, photo - defaults to medium).
|
59
|
+
# Only works for real devices.
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
#
|
63
|
+
# @driver.start_recording_screen
|
64
|
+
# @driver.start_recording_screen video_type: 'h264', time_limit: '260'
|
65
|
+
#
|
66
|
+
|
67
|
+
# @since 1.3.4
|
68
|
+
# @!method start_performance_record(timeout: 300000, profile_name: 'Activity Monitor')
|
69
|
+
#
|
70
|
+
# This is a blocking application.
|
71
|
+
# @param [Integer|String] timeout: The maximum count of milliseconds to record the profiling information.
|
72
|
+
# @param [String] profile_name: The name of existing performance profile to apply.
|
73
|
+
# Execute `instruments -s` to show the list of available profiles.
|
74
|
+
# Note, that not all profiles are supported on mobile devices.
|
75
|
+
# @param [Integer|String] pid: The ID of the process to measure the performance for.
|
76
|
+
# Set it to `current` in order to measure the performance of
|
77
|
+
# the process, which belongs to the currently active application.
|
78
|
+
# All processes running on the device are measured if
|
79
|
+
# pid is unset (the default setting). Setting process ID while
|
80
|
+
# device under test is Simulator might require `instruments` to be launched
|
81
|
+
# with sudo privileges, which is not supported and will throw a timeout exception.
|
82
|
+
# @return nil
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
#
|
86
|
+
# @driver.start_performance_record # default: (timeout: 300000, profile_name: 'Activity Monitor')
|
87
|
+
# @driver.start_performance_record(timeout: 300000, profile_name: 'Activity Monitor')
|
88
|
+
#
|
89
|
+
|
90
|
+
# @since 1.3.4
|
91
|
+
# @!method get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor', remote_path: nil, user: nil, pass: nil, method: 'PUT')
|
92
|
+
#
|
93
|
+
# This is a blocking application.
|
94
|
+
#
|
95
|
+
# @param [String] save_file_path: A path to save data as zipped .trace file
|
96
|
+
# @param [String] profile_name: The name of existing performance profile to apply.
|
97
|
+
# Execute `instruments -s` to show the list of available profiles.
|
98
|
+
# Note, that not all profiles are supported on mobile devices.
|
99
|
+
# @param [String] save_file_path: The name of existing performance profile to apply.
|
100
|
+
# Execute `instruments -s` to show the list of available profiles.
|
101
|
+
# Note, that not all profiles are supported on mobile devices.
|
102
|
+
# @param [String] remote_path: The path to the remote location, where the resulting zipped .trace file should be uploaded.
|
103
|
+
# The following protocols are supported: http/https, ftp.
|
104
|
+
# Null or empty string value (the default setting) means the content of resulting
|
105
|
+
# file should be zipped, encoded as Base64 and passed as the endpount response value.
|
106
|
+
# An exception will be thrown if the generated file is too big to
|
107
|
+
# fit into the available process memory.
|
108
|
+
# @param [String] user: The name of the user for the remote authentication. Only works if `remotePath` is provided.
|
109
|
+
# @param [String] pass: The password for the remote authentication. Only works if `remotePath` is provided.
|
110
|
+
# @param [String] method: The http multipart upload method name. Only works if `remotePath` is provided.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
#
|
114
|
+
# @driver.get_performance_record
|
115
|
+
# @driver.get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor')
|
116
|
+
|
117
|
+
# @since 1.6.0
|
118
|
+
# @!method battery_info
|
119
|
+
#
|
120
|
+
# Get battery information.
|
121
|
+
#
|
122
|
+
# @return [Hash] Return battery level and battery state from the target real device. (Simulator has no battery.)
|
123
|
+
# https://developer.apple.com/documentation/uikit/uidevice/ 's `batteryLevel` and `batteryState`.
|
124
|
+
# Battery level in range [0.0, 1.0], where 1.0 means 100% charge. -1 is returned
|
125
|
+
# if the actual value cannot be retrieved from the system.
|
126
|
+
# Battery state. The following symbols are possible
|
127
|
+
# `:unplugged, :charging, :full`
|
128
|
+
#
|
129
|
+
# @example
|
130
|
+
#
|
131
|
+
# @driver.battery_info #=> { state: :full, level: 0.7 }
|
132
|
+
#
|
133
|
+
|
134
|
+
# rubocop:enable Metrics/LineLength
|
135
|
+
|
136
|
+
####
|
137
|
+
## class << self
|
138
|
+
####
|
139
|
+
|
140
|
+
class << self
|
141
|
+
def extended(_mod)
|
142
|
+
# Override
|
143
|
+
::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
|
144
|
+
def hide_keyboard(close_key = nil, strategy = nil)
|
145
|
+
option = {}
|
146
|
+
|
147
|
+
option[:key] = close_key if close_key
|
148
|
+
option[:strategy] = strategy if strategy
|
149
|
+
|
150
|
+
execute :hide_keyboard, {}, option
|
151
|
+
end
|
192
152
|
end
|
193
|
-
end
|
194
|
-
|
195
|
-
Appium::Core::Device.add_endpoint_method(:get_performance_record) do
|
196
|
-
# rubocop:disable Metrics/ParameterLists
|
197
|
-
def get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor',
|
198
|
-
remote_path: nil, user: nil, pass: nil, method: 'PUT')
|
199
|
-
option = ::Appium::Core::Device::ScreenRecord.new(
|
200
|
-
remote_path: remote_path, user: user, pass: pass, method: method
|
201
|
-
).upload_option
|
202
|
-
|
203
|
-
option[:profileName] = profile_name
|
204
|
-
result = execute_script 'mobile: stopPerfRecord', option
|
205
153
|
|
206
|
-
|
154
|
+
# Override
|
155
|
+
::Appium::Core::Device.add_endpoint_method(:background_app) do
|
156
|
+
def background_app(duration = 0)
|
157
|
+
# https://github.com/appium/ruby_lib/issues/500, https://github.com/appium/appium/issues/7741
|
158
|
+
# `execute :background_app, {}, seconds: { timeout: duration_milli_sec }` works over Appium 1.6.4
|
159
|
+
duration_milli_sec = duration.nil? ? nil : duration * 1000
|
160
|
+
execute :background_app, {}, seconds: { timeout: duration_milli_sec }
|
161
|
+
end
|
207
162
|
end
|
208
|
-
# rubocop:enable Metrics/ParameterLists
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def add_screen_recording
|
213
|
-
Appium::Core::Device.add_endpoint_method(:start_recording_screen) do
|
214
|
-
# rubocop:disable Metrics/ParameterLists
|
215
|
-
def start_recording_screen(remote_path: nil, user: nil, pass: nil, method: nil, force_restart: nil,
|
216
|
-
video_type: 'mp4', time_limit: '180', video_quality: 'medium')
|
217
|
-
option = ::Appium::Core::Device::ScreenRecord.new(
|
218
|
-
remote_path: remote_path, user: user, pass: pass, method: method, force_restart: force_restart
|
219
|
-
).upload_option
|
220
163
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
execute(:start_recording_screen, {}, { options: option })
|
226
|
-
end
|
227
|
-
# rubocop:enable Metrics/ParameterLists
|
164
|
+
Performance.add_methods
|
165
|
+
Screen.add_methods
|
166
|
+
Battery.add_methods
|
228
167
|
end
|
229
|
-
end
|
230
|
-
end #
|
231
|
-
end # module
|
232
|
-
end # module
|
233
|
-
end # module
|
168
|
+
end # class << self
|
169
|
+
end # module Device
|
170
|
+
end # module Xcuitest
|
171
|
+
end # module Ios
|
172
|
+
end # module Core
|
234
173
|
end # module Appium
|