appium_lib_core 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,42 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Appium
|
4
|
+
module Core
|
5
|
+
module Android
|
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, label: nil)
|
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
|
+
params[:label] = label unless label.nil?
|
33
|
+
|
34
|
+
execute(:set_clipboard, {}, params)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end # module Clipboard
|
39
|
+
end # module Device
|
40
|
+
end # module Android
|
41
|
+
end # module Core
|
42
|
+
end # module Appium
|
@@ -1,168 +1,170 @@
|
|
1
1
|
module Appium
|
2
|
-
module
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
2
|
+
module Core
|
3
|
+
module Android
|
4
|
+
module Device
|
5
|
+
module Emulator
|
6
|
+
GSM_CALL_ACTIONS = [:call, :accept, :cancel, :hold].freeze
|
7
|
+
|
8
|
+
GSM_VOICE_STATES = [:on, :off, :denied, :searching, :roaming, :home, :unregistered].freeze
|
9
|
+
|
10
|
+
GSM_SIGNALS = { none_or_unknown: 0, poor: 1, moderate: 2, good: 3, great: 4 }.freeze
|
11
|
+
|
12
|
+
# :gsm // GSM/CSD (up: 14.4, down: 14.4).
|
13
|
+
# :scsd // HSCSD (up: 14.4, down: 57.6).
|
14
|
+
# :gprs // GPRS (up: 28.8, down: 57.6).
|
15
|
+
# :edge // EDGE/EGPRS (up: 473.6, down: 473.6).
|
16
|
+
# :umts // UMTS/3G (up: 384.0, down: 384.0).
|
17
|
+
# :hsdpa // HSDPA (up: 5760.0, down: 13,980.0).
|
18
|
+
# :lte // LTE (up: 58,000, down: 173,000).
|
19
|
+
# :evdo // EVDO (up: 75,000, down: 280,000).
|
20
|
+
# :full // No limit, the default (up: 0.0, down: 0.0).
|
21
|
+
NET_SPEED = [:gsm, :scsd, :gprs, :edge, :umts, :hsdpa, :lte, :evdo, :full].freeze
|
22
|
+
|
23
|
+
POWER_AC_STATE = [:on, :off].freeze
|
24
|
+
|
25
|
+
# @!method send_sms(phone_number:, message:)
|
26
|
+
# Emulate send SMS event on the connected emulator.
|
27
|
+
#
|
28
|
+
# @param [String] phone_number: The phone number of message sender
|
29
|
+
# @param [String] message: The message to send
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
#
|
33
|
+
# @driver.send_sms phone_number: '00000000000', message: 'test message'
|
34
|
+
#
|
35
|
+
|
36
|
+
# @!method gsm_call(phone_number:, action:)
|
37
|
+
# Emulate GSM call event on the connected emulator.
|
38
|
+
#
|
39
|
+
# @param [String] phone_number: The phone number of message sender
|
40
|
+
# @param [Hash] action: One of available GSM call actions. Available action is GSM_CALL_ACTION.
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
#
|
44
|
+
# @driver.gsm_call phone_number: '00000000000', action: :call
|
45
|
+
#
|
46
|
+
|
47
|
+
# @!method gsm_signal(signal_strength)
|
48
|
+
# Emulate GSM signal strength change event on the connected emulator.
|
49
|
+
#
|
50
|
+
# @param [Hash] signal_strength One of available GSM signal strength. Available action is GSM_SIGNAL.
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
#
|
54
|
+
# @driver.gsm_signal :good
|
55
|
+
#
|
56
|
+
|
57
|
+
# @!method gsm_voice(state)
|
58
|
+
# Emulate GSM voice event on the connected emulator.
|
59
|
+
#
|
60
|
+
# @param [Hash] state One of available GSM voice state. Available action is GSM_VOICE_STATE.
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
#
|
64
|
+
# @driver.gsm_voice :on
|
65
|
+
#
|
66
|
+
|
67
|
+
# @!method set_network_speed(netspeed)
|
68
|
+
# Emulate network speed change event on the connected emulator.
|
69
|
+
#
|
70
|
+
# @param [Hash] netspeed One of available Network Speed values. Available action is NET_SPEED.
|
71
|
+
#
|
72
|
+
# @example
|
73
|
+
#
|
74
|
+
# @driver.set_network_speed :gsm
|
75
|
+
#
|
76
|
+
|
77
|
+
# @!method set_power_capacity(percent)
|
78
|
+
# Emulate power capacity change on the connected emulator.
|
79
|
+
#
|
80
|
+
# @param [Integer] percent Percentage value in range [0, 100].
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
#
|
84
|
+
# @driver.set_power_capacity 10
|
85
|
+
#
|
86
|
+
|
87
|
+
# @!method set_power_ac(state)
|
88
|
+
# Emulate power state change on the connected emulator.
|
89
|
+
#
|
90
|
+
# @param [Hash] state One of available power AC state. Available action is POWER_AC_STATE.
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
#
|
94
|
+
# @driver.set_power_ac :on
|
95
|
+
#
|
96
|
+
|
97
|
+
####
|
98
|
+
## self.emulator_commands
|
99
|
+
####
|
100
|
+
|
101
|
+
def self.add_methods
|
102
|
+
::Appium::Core::Device.add_endpoint_method(:send_sms) do
|
103
|
+
def send_sms(phone_number:, message:)
|
104
|
+
execute(:send_sms, {}, { phoneNumber: phone_number, message: message })
|
105
|
+
end
|
104
106
|
end
|
105
|
-
end
|
106
107
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
::Appium::Core::Device.add_endpoint_method(:gsm_call) do
|
109
|
+
def gsm_call(phone_number:, action:)
|
110
|
+
unless GSM_CALL_ACTIONS.member? action.to_sym
|
111
|
+
raise "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}."
|
112
|
+
end
|
112
113
|
|
113
|
-
|
114
|
+
execute(:gsm_call, {}, { phoneNumber: phone_number, action: action })
|
115
|
+
end
|
114
116
|
end
|
115
|
-
end
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
118
|
+
::Appium::Core::Device.add_endpoint_method(:gsm_signal) do
|
119
|
+
def gsm_signal(signal_strength)
|
120
|
+
raise "#{signal_strength} should be member of #{GSM_SIGNALS} " if GSM_SIGNALS[signal_strength.to_sym].nil?
|
120
121
|
|
121
|
-
|
122
|
+
execute(:gsm_signal, {}, { signalStrengh: GSM_SIGNALS[signal_strength] })
|
123
|
+
end
|
122
124
|
end
|
123
|
-
end
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
::Appium::Core::Device.add_endpoint_method(:gsm_voice) do
|
127
|
+
def gsm_voice(state)
|
128
|
+
unless GSM_VOICE_STATES.member? state.to_sym
|
129
|
+
raise "The state should be member of #{GSM_VOICE_STATES}. Not #{state}."
|
130
|
+
end
|
130
131
|
|
131
|
-
|
132
|
+
execute(:gsm_voice, {}, { state: state })
|
133
|
+
end
|
132
134
|
end
|
133
|
-
end
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
::Appium::Core::Device.add_endpoint_method(:set_network_speed) do
|
137
|
+
def set_network_speed(netspeed)
|
138
|
+
unless NET_SPEED.member? netspeed.to_sym
|
139
|
+
raise "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}."
|
140
|
+
end
|
140
141
|
|
141
|
-
|
142
|
+
execute(:set_network_speed, {}, { netspeed: netspeed })
|
143
|
+
end
|
142
144
|
end
|
143
|
-
end
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
::Appium::Core::Device.add_endpoint_method(:set_power_capacity) do
|
147
|
+
def set_power_capacity(percent)
|
148
|
+
unless (0..100).member? percent
|
149
|
+
raise "The percent should be between 0 and 100. Not #{percent}."
|
150
|
+
end
|
150
151
|
|
151
|
-
|
152
|
+
execute(:set_power_capacity, {}, { percent: percent })
|
153
|
+
end
|
152
154
|
end
|
153
|
-
end
|
154
155
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
::Appium::Core::Device.add_endpoint_method(:set_power_ac) do
|
157
|
+
def set_power_ac(state)
|
158
|
+
unless POWER_AC_STATE.member? state.to_sym
|
159
|
+
raise "The state should be member of #{POWER_AC_STATE}. Not #{state}."
|
160
|
+
end
|
160
161
|
|
161
|
-
|
162
|
+
execute(:set_power_ac, {}, { state: state })
|
163
|
+
end
|
162
164
|
end
|
163
|
-
end
|
164
|
-
end #
|
165
|
-
end # module
|
166
|
-
end # module
|
167
|
-
end # module
|
165
|
+
end # def self.emulator_commands
|
166
|
+
end # module Emulator
|
167
|
+
end # module Device
|
168
|
+
end # module Android
|
169
|
+
end # module Core
|
168
170
|
end # module Appium
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Appium
|
2
|
+
module Core
|
3
|
+
module Android
|
4
|
+
module Device
|
5
|
+
module Network
|
6
|
+
def self.add_methods
|
7
|
+
::Appium::Core::Device.add_endpoint_method(:get_network_connection) do
|
8
|
+
def get_network_connection
|
9
|
+
execute :get_network_connection
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
::Appium::Core::Device.add_endpoint_method(:toggle_wifi) do
|
14
|
+
def toggle_wifi
|
15
|
+
execute :toggle_wifi
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
::Appium::Core::Device.add_endpoint_method(:toggle_data) do
|
20
|
+
def toggle_data
|
21
|
+
execute :toggle_data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
::Appium::Core::Device.add_endpoint_method(:set_network_connection) do
|
26
|
+
def set_network_connection(mode)
|
27
|
+
# TODO. Update set_network_connection as well
|
28
|
+
# connection_type = {airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
|
29
|
+
# raise ArgumentError, 'Invalid connection type' unless type_to_values.keys.include? mode
|
30
|
+
# type = connection_type[mode]
|
31
|
+
# execute :set_network_connection, {}, type: type
|
32
|
+
execute :set_network_connection, {}, type: mode
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
::Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do
|
37
|
+
def toggle_airplane_mode
|
38
|
+
execute :toggle_airplane_mode
|
39
|
+
end
|
40
|
+
alias_method :toggle_flight_mode, :toggle_airplane_mode
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end # module Network
|
44
|
+
end # module Device
|
45
|
+
end # module Android
|
46
|
+
end # module Core
|
47
|
+
end # module Appium
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Appium
|
2
|
+
module Core
|
3
|
+
module Android
|
4
|
+
module Device
|
5
|
+
module Performance
|
6
|
+
def self.add_methods
|
7
|
+
::Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do
|
8
|
+
def get_performance_data_types
|
9
|
+
execute :get_performance_data_types
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
::Appium::Core::Device.add_endpoint_method(:get_performance_data) do
|
14
|
+
def get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
|
15
|
+
execute(:get_performance_data, {},
|
16
|
+
packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end # module Performance
|
21
|
+
end # module Device
|
22
|
+
end # module Android
|
23
|
+
end # module Core
|
24
|
+
end # module Appium
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Appium
|
2
|
+
module Core
|
3
|
+
module Android
|
4
|
+
module Device
|
5
|
+
module Screen
|
6
|
+
def self.add_methods
|
7
|
+
::Appium::Core::Device.add_endpoint_method(:get_display_density) do
|
8
|
+
def get_display_density
|
9
|
+
execute :get_display_density
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
::Appium::Core::Device.add_endpoint_method(:start_recording_screen) do
|
14
|
+
# rubocop:disable Metrics/ParameterLists
|
15
|
+
def start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil,
|
16
|
+
video_size: nil, time_limit: '180', bit_rate: nil, bug_report: nil)
|
17
|
+
option = ::Appium::Core::Device::ScreenRecord.new(
|
18
|
+
remote_path: remote_path, user: user, pass: pass, method: method, force_restart: force_restart
|
19
|
+
).upload_option
|
20
|
+
|
21
|
+
option[:videoSize] = video_size unless video_size.nil?
|
22
|
+
option[:timeLimit] = time_limit
|
23
|
+
option[:bitRate] = bit_rate unless bit_rate.nil?
|
24
|
+
|
25
|
+
unless bug_report.nil?
|
26
|
+
raise 'bug_report should be true or false' unless [true, false].member?(bug_report)
|
27
|
+
option[:bugReport] = bug_report
|
28
|
+
end
|
29
|
+
|
30
|
+
execute(:start_recording_screen, {}, { options: option })
|
31
|
+
end
|
32
|
+
# rubocop:enable Metrics/ParameterLists
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end # module Screen
|
36
|
+
end # module Device
|
37
|
+
end # module Android
|
38
|
+
end # module Core
|
39
|
+
end # module Appium
|