appium_lib_core 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9bb0e41715b40a247cce0ca6c129aa782269d21
4
- data.tar.gz: 88cf6d66bdc6ad88e83971ab6234279e703a2203
3
+ metadata.gz: 703373935a027f386911efb13088fbcc09e655a2
4
+ data.tar.gz: 0aa3d1af1e2fe7f5ef1c81d05564698b744b5c8e
5
5
  SHA512:
6
- metadata.gz: 2df417c53c2e9001002bd23f00ccd3938d436a4736914fb372b3978f968e1d87f247fd1b4d6706bbd67b3bf50b77abefdcdeb7ab3838bee9b257e8f1f74cec34
7
- data.tar.gz: 88eb0ca4828ea2bbf052012557b204a0346d0a205485804e4e6c68bea7f70d960ada2e91835d262f4dc594a1e463738c3e55868e612012e7152ed890d332a6ae
6
+ metadata.gz: eba28378ec06ae4dd9475478aedb90d8eed232fe5d5c2b4f0e5b285dc1709ae5febab7e878bd0d0fb33c40c8f282a805fddc8b8936a9f10c4732f3cf44afadd4
7
+ data.tar.gz: da507de703f77f94d00a3182476ca7fca9933a1f6481dc3c1498ec93121c3e03584763e3d00f440e150c6cddfc70aeb4986a552bdfa08cd5b85aa4be041521af
@@ -8,6 +8,21 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  ### Deprecations
10
10
 
11
+ ## [1.6.0] - 2018-05-08
12
+ ### Enhancements
13
+ - **Breaking Change**
14
+ - Change the results of `app_state`.
15
+ - Before: A number or const.
16
+ - `0, 1, 2, 3, 4` or `NOT_INSTALLED, NOT_RUNNING, RUNNING_IN_BACKGROUND_SUSPENDED, RUNNING_IN_BACKGROUND, RUNNING_IN_FOREGROUND`
17
+ - After: Symbol.
18
+ - `:not_installed, :not_running, :running_in_background_suspended, :running_in_background, :running_in_foreground`
19
+ - add `battery_info` to get battery information
20
+ - add `is_keyboard_shown` for iOS ( see also https://github.com/appium/appium-xcuitest-driver/pull/664/files )
21
+
22
+ ### Bug fixes
23
+
24
+ ### Deprecations
25
+
11
26
  ## [1.5.1] - 2018-04-25
12
27
  ### Enhancements
13
28
 
@@ -52,14 +52,6 @@ module Appium
52
52
  # @driver.get_display_density # 320
53
53
  #
54
54
 
55
- # @!method is_keyboard_shown
56
- # Get whether keyboard is displayed or not.
57
- # @return [Boolean] Return true if keyboard is shown. Return false if keyboard is hidden.
58
- #
59
- # @example
60
- # @driver.is_keyboard_shown # false
61
- #
62
-
63
55
  # @!method get_network_connection
64
56
  # Get the device network connection current status
65
57
  # See set_network_connection method for return value
@@ -286,12 +278,6 @@ module Appium
286
278
  end
287
279
  end
288
280
 
289
- Appium::Core::Device.add_endpoint_method(:is_keyboard_shown) do
290
- def is_keyboard_shown # rubocop:disable Naming/PredicateName for compatibility
291
- execute :is_keyboard_shown
292
- end
293
- end
294
-
295
281
  Appium::Core::Device.add_endpoint_method(:get_network_connection) do
296
282
  def get_network_connection
297
283
  execute :get_network_connection
@@ -6,6 +6,7 @@ module Appium
6
6
  def self.for(target)
7
7
  target.extend Appium::Android::Device
8
8
  Core::Android::SearchContext.extend
9
+ target.extend Appium::Core::Android::Uiautomator2::Device
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,50 @@
1
+ module Appium
2
+ module Core
3
+ module Android
4
+ module Uiautomator2
5
+ module Device
6
+ extend Forwardable
7
+
8
+ # @since 1.6.0
9
+ # @!method battery_info
10
+ #
11
+ # Get battery information.
12
+ #
13
+ # @return [Hash] Return battery level and battery state.
14
+ # Battery level in range [0.0, 1.0], where 1.0 means 100% charge. -1 is returned
15
+ # if the actual value cannot be retrieved from the system.
16
+ # Battery state. The following symbols are possible
17
+ # `:unknown, :charging, :discharging, :not_charging, :full`
18
+ #
19
+ # @example
20
+ #
21
+ # @driver.battery_info #=> { state: :charging, level: 0.7 }
22
+ #
23
+
24
+ ####
25
+ ## class << self
26
+ ####
27
+
28
+ class << self
29
+ def extended(_mod)
30
+ ::Appium::Core::Device.add_endpoint_method(:battery_info) do
31
+ def battery_info
32
+ response = execute_script 'mobile: batteryInfo', {}
33
+
34
+ state = case response['state']
35
+ when 2, 3, 4, 5
36
+ ::Appium::Core::Device::BatteryStatus::ANDROID[response['state']]
37
+ else
38
+ Appium::Logger.warn("The state is unknown or undefined: #{response['state']}")
39
+ ::Appium::Core::Device::BatteryStatus::ANDROID[1] # :unknown
40
+ end
41
+ { state: state, level: response['level'] }
42
+ end
43
+ end
44
+ end
45
+ end # class << self
46
+ end # module Device
47
+ end # module Uiautomator2
48
+ end # module Android
49
+ end # module Core
50
+ end # module Appium
@@ -1,4 +1,6 @@
1
1
  # loaded in common/driver.rb
2
2
  require_relative 'android/search_context'
3
3
  require_relative 'android/device'
4
+
4
5
  require_relative 'android/uiautomator2/bridge'
6
+ require_relative 'android/uiautomator2/device'
@@ -46,7 +46,8 @@ module Appium
46
46
  update_settings: [:post, 'session/:session_id/appium/settings'.freeze],
47
47
  stop_recording_screen: [:post, 'session/:session_id/appium/stop_recording_screen'.freeze],
48
48
  start_recording_screen: [:post, 'session/:session_id/appium/start_recording_screen'.freeze],
49
- compare_images: [:post, 'session/:session_id/appium/compare_images'.freeze]
49
+ compare_images: [:post, 'session/:session_id/appium/compare_images'.freeze],
50
+ is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze]
50
51
  }.freeze
51
52
 
52
53
  COMMAND_ANDROID = {
@@ -57,7 +58,6 @@ module Appium
57
58
  current_package: [:get, 'session/:session_id/appium/device/current_package'.freeze],
58
59
  get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'.freeze],
59
60
  get_display_density: [:get, 'session/:session_id/appium/device/display_density'.freeze],
60
- is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze],
61
61
  toggle_wifi: [:post, 'session/:session_id/appium/device/toggle_wifi'.freeze],
62
62
  toggle_data: [:post, 'session/:session_id/appium/device/toggle_data'.freeze],
63
63
  toggle_location_services: [:post, 'session/:session_id/appium/device/toggle_location_services'.freeze],
@@ -1,23 +1,23 @@
1
1
  module Appium
2
- # Perform a series of gestures, one after another. Gestures are chained
3
- # together and only performed when `perform()` is called. Default is conducted by global driver.
4
- #
5
- # Each method returns the object itself, so calls can be chained.
6
- #
7
- # Consider to use W3C spec touch action like the followings.
8
- # https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
9
- # https://github.com/appium/ruby_lib_core/blob/master/test/functional/android/webdriver/w3c_actions_test.rb
10
- # https://github.com/appium/ruby_lib_core/blob/master/test/functional/ios/webdriver/w3c_actions_test.rb
11
- #
12
- # @example
13
- #
14
- # @driver = Appium::Core.for(self, opts).start_driver
15
- # action = TouchAction.new(@driver).press(x: 45, y: 100).wait(5).release
16
- # action.perform
17
- # action = TouchAction.new(@driver).swipe(....)
18
- # action.perform
19
- #
20
2
  module Core
3
+ # Perform a series of gestures, one after another. Gestures are chained
4
+ # together and only performed when `perform()` is called. Default is conducted by global driver.
5
+ #
6
+ # Each method returns the object itself, so calls can be chained.
7
+ #
8
+ # Consider to use W3C spec touch action like the followings.
9
+ # https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
10
+ # https://github.com/appium/ruby_lib_core/blob/master/test/functional/android/webdriver/w3c_actions_test.rb
11
+ # https://github.com/appium/ruby_lib_core/blob/master/test/functional/ios/webdriver/w3c_actions_test.rb
12
+ #
13
+ # @example
14
+ #
15
+ # @driver = Appium::Core.for(self, opts).start_driver
16
+ # action = TouchAction.new(@driver).press(x: 45, y: 100).wait(5).release
17
+ # action.perform
18
+ # action = TouchAction.new(@driver).swipe(....)
19
+ # action.perform
20
+ #
21
21
  class TouchAction
22
22
  ACTIONS = %i(move_to long_press double_tap two_finger_tap press release tap wait perform).freeze
23
23
  COMPLEX_ACTIONS = %i(swipe).freeze
@@ -1,5 +1,5 @@
1
- require_relative 'device/touch_actions'
2
- require_relative 'device/multi_touch'
1
+ require_relative 'common/touch_action/touch_actions'
2
+ require_relative 'common/touch_action/multi_touch'
3
3
  require_relative 'device/screen_record'
4
4
  require_relative 'device/app_state'
5
5
  require_relative 'device/clipboard_content_type'
@@ -141,20 +141,20 @@ module Appium
141
141
 
142
142
  # Get the status of an existing application on the device.
143
143
  # State:
144
- # AppState::NOT_INSTALLED : The current application state cannot be determined/is unknown
145
- # AppState::NOT_RUNNING : The application is not running
146
- # AppState::RUNNING_IN_BACKGROUND_SUSPENDED : The application is running in the background and is suspended
147
- # AppState::RUNNING_IN_BACKGROUND : The application is running in the background and is not suspended
148
- # AppState::RUNNING_IN_FOREGROUND : The application is running in the foreground
144
+ # :not_installed : The current application state cannot be determined/is unknown
145
+ # :not_running : The application is not running
146
+ # :running_in_background_suspended : The application is running in the background and is suspended
147
+ # :running_in_background : The application is running in the background and is not suspended
148
+ # :running_in_foreground : The application is running in the foreground
149
149
  #
150
150
  # For more details: https://developer.apple.com/documentation/xctest/xcuiapplicationstate
151
151
  #
152
152
  # @param [String] bundle_id A target app's bundle id
153
- # @return [AppManagement::APP_STATE_NOT_INSTALLED|AppManagement::APP_STATE_NOT_RUNNING|APP_STATE_RUNNING_IN_BACKGROUND_SUSPEND|AppManagement::APP_STATE_RUNNING_IN_BACKGROUND|AppManagement::APP_STATE_RUNNING_IN_FOREGROUND] A number of the state
153
+ # @return [AppState::STATUS] A number of the state
154
154
  #
155
155
  # @example
156
156
  #
157
- # @driver.app_state("io.appium.bundle") #=> 1
157
+ # @driver.app_state("io.appium.bundle") #=> :not_running
158
158
  #
159
159
 
160
160
  # @!method app_strings(language = nil)
@@ -205,6 +205,14 @@ module Appium
205
205
  # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
206
206
  #
207
207
 
208
+ # @!method is_keyboard_shown
209
+ # Get whether keyboard is displayed or not.
210
+ # @return [Boolean] Return true if keyboard is shown. Return false if keyboard is hidden.
211
+ #
212
+ # @example
213
+ # @driver.is_keyboard_shown # false
214
+ #
215
+
208
216
  # @!method keyevent(key, metastate = nil)
209
217
  # Send keyevent on the device.(Only for Selendroid)
210
218
  # http://developer.android.com/reference/android/view/KeyEvent.html
@@ -450,17 +458,6 @@ module Appium
450
458
  end
451
459
  end
452
460
 
453
- add_endpoint_method(:hide_keyboard) do
454
- def hide_keyboard(close_key = nil, strategy = nil)
455
- option = {}
456
-
457
- option[:key] = close_key || 'Done' # default to Done key.
458
- option[:strategy] = strategy || :pressKey # default to pressKey
459
-
460
- execute :hide_keyboard, {}, option
461
- end
462
- end
463
-
464
461
  add_endpoint_method(:take_element_screenshot) do
465
462
  def take_element_screenshot(element, png_path)
466
463
  result = execute :take_element_screenshot, id: element.ref
@@ -520,6 +517,7 @@ module Appium
520
517
  add_app_management
521
518
  add_device_lock
522
519
  add_file_management
520
+ add_keyboard
523
521
  Core::Device::ImageComparison.extended
524
522
  end
525
523
 
@@ -719,16 +717,8 @@ module Appium
719
717
  response = execute :app_state, {}, appId: app_id
720
718
 
721
719
  case response
722
- when 0
723
- ::Appium::Core::Device::AppState::NOT_INSTALLED
724
- when 1
725
- ::Appium::Core::Device::AppState::NOT_RUNNING
726
- when 2
727
- ::Appium::Core::Device::AppState::RUNNING_IN_BACKGROUND_SUSPENDED
728
- when 3
729
- ::Appium::Core::Device::AppState::RUNNING_IN_BACKGROUND
730
- when 4
731
- ::Appium::Core::Device::AppState::RUNNING_IN_FOREGROUND
720
+ when 0, 1, 2, 3, 4
721
+ ::Appium::Core::Device::AppState::STATUS[response]
732
722
  else
733
723
  ::Appium::Logger.debug("Unexpected status in app_state: #{response}")
734
724
  response
@@ -765,6 +755,25 @@ module Appium
765
755
  end
766
756
  end
767
757
 
758
+ def add_keyboard
759
+ add_endpoint_method(:hide_keyboard) do
760
+ def hide_keyboard(close_key = nil, strategy = nil)
761
+ option = {}
762
+
763
+ option[:key] = close_key || 'Done' # default to Done key.
764
+ option[:strategy] = strategy || :pressKey # default to pressKey
765
+
766
+ execute :hide_keyboard, {}, option
767
+ end
768
+ end
769
+
770
+ add_endpoint_method(:is_keyboard_shown) do
771
+ def is_keyboard_shown # rubocop:disable Naming/PredicateName for compatibility
772
+ execute :is_keyboard_shown
773
+ end
774
+ end
775
+ end
776
+
768
777
  def add_touch_actions
769
778
  add_endpoint_method(:touch_actions) do
770
779
  def touch_actions(actions)
@@ -2,11 +2,13 @@ module Appium
2
2
  module Core
3
3
  module Device
4
4
  class AppState
5
- NOT_INSTALLED = 0
6
- NOT_RUNNING = 1
7
- RUNNING_IN_BACKGROUND_SUSPENDED = 2
8
- RUNNING_IN_BACKGROUND = 3
9
- RUNNING_IN_FOREGROUND = 4
5
+ STATUS = [
6
+ :not_installed, # 0
7
+ :not_running, # 1
8
+ :running_in_background_suspended, # 2
9
+ :running_in_background, # 3
10
+ :running_in_foreground # 4
11
+ ].freeze
10
12
  end
11
13
  end
12
14
  end
@@ -0,0 +1,23 @@
1
+ module Appium
2
+ module Core
3
+ module Device
4
+ module BatteryStatus
5
+ ANDROID = [
6
+ :undefined, # 0, dummy
7
+ :unknown, # 1
8
+ :charging, # 2
9
+ :discharging, # 3
10
+ :not_charging, # 4
11
+ :full # 5
12
+ ].freeze
13
+
14
+ IOS = [
15
+ :unknown, # 0
16
+ :unplugged, # 1
17
+ :charging, # 2
18
+ :full # 3
19
+ ].freeze
20
+ end
21
+ end
22
+ end
23
+ end
@@ -109,6 +109,23 @@ module Appium
109
109
  # @driver.get_performance_record
110
110
  # @driver.get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor')
111
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
+
112
129
  # rubocop:enable Metrics/LineLength
113
130
 
114
131
  ####
@@ -117,8 +134,6 @@ module Appium
117
134
 
118
135
  class << self
119
136
  def extended(_mod)
120
- ::Appium::Core::Device.extend_webdriver_with_forwardable
121
-
122
137
  # Override
123
138
  ::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
124
139
  def hide_keyboard(close_key = nil, strategy = nil)
@@ -143,10 +158,28 @@ module Appium
143
158
 
144
159
  add_performance
145
160
  add_screen_recording
161
+ add_battery_info
146
162
  end
147
163
 
148
164
  private
149
165
 
166
+ def add_battery_info
167
+ Appium::Core::Device.add_endpoint_method(:battery_info) do
168
+ def battery_info
169
+ response = execute_script 'mobile: batteryInfo', {}
170
+
171
+ state = case response['state']
172
+ when 1, 2, 3
173
+ ::Appium::Core::Device::BatteryStatus::IOS[response['state']]
174
+ else
175
+ Appium::Logger.warn("The state is unknown or undefined: #{response['state']}")
176
+ ::Appium::Core::Device::BatteryStatus::IOS[0] # :unknown
177
+ end
178
+ { state: state, level: response['level'] }
179
+ end
180
+ end
181
+ end
182
+
150
183
  def add_performance
151
184
  Appium::Core::Device.add_endpoint_method(:start_performance_record) do
152
185
  def start_performance_record(timeout: 300_000, profile_name: 'Activity Monitor', pid: nil)
@@ -19,7 +19,7 @@ module Appium
19
19
  # find_elements :class_chain, 'XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]'
20
20
  #
21
21
  # # matching predicate. <code>`</code> is the mark.
22
- # find_elements :class_chain, 'XCUIElementTypeWindow[`visible = 1][`name = \"bla\"`]'
22
+ # find_elements :class_chain, 'XCUIElementTypeWindow[`visible = 1][`name = "bla"`]'
23
23
  #
24
24
  # # containing predicate. `$` is the mark.
25
25
  # # Require appium-xcuitest-driver 2.54.0+
@@ -5,3 +5,5 @@ require_relative 'ios/device'
5
5
  require_relative 'ios/xcuitest/search_context'
6
6
  require_relative 'ios/xcuitest/device'
7
7
  require_relative 'ios/xcuitest/bridge'
8
+
9
+ require_relative 'device/battery_status'
@@ -1,6 +1,6 @@
1
1
  module Appium
2
2
  module Core
3
- VERSION = '1.5.1'.freeze unless defined? ::Appium::Core::VERSION
4
- DATE = '2018-04-25'.freeze unless defined? ::Appium::Core::DATE
3
+ VERSION = '1.6.0'.freeze unless defined? ::Appium::Core::VERSION
4
+ DATE = '2018-05-08'.freeze unless defined? ::Appium::Core::DATE
5
5
  end
6
6
  end
@@ -1,3 +1,13 @@
1
+ #### v1.6.0 2018-05-08
2
+
3
+ - [37a35f0](https://github.com/appium/ruby_lib_core/commit/37a35f022d35f43a9770c17e25b8fa3c57737dd6) Release 1.6.0
4
+ - [0a5134c](https://github.com/appium/ruby_lib_core/commit/0a5134c80939484301250331bc77b384bc01cf1c) fix an example
5
+ - [59a920f](https://github.com/appium/ruby_lib_core/commit/59a920fc6a8e42503f4314f6cfd1242326573559) Add battery info (#85)
6
+ - [1e9717f](https://github.com/appium/ruby_lib_core/commit/1e9717fae8231b87c906ade40cea4ca4bebe5262) add is_keyboard_shown for iOS (#86)
7
+ - [48ae579](https://github.com/appium/ruby_lib_core/commit/48ae57975dbf17d0d097d49a6b8598ad18cf4c63) Update CHANGELOG.md
8
+ - [9ae597c](https://github.com/appium/ruby_lib_core/commit/9ae597c6fdea0abb5f7292bb2c3e02dc859ecb3d) change the response of app_state (#84)
9
+
10
+
1
11
  #### v1.5.1 2018-04-25
2
12
 
3
13
  - [27f6149](https://github.com/appium/ruby_lib_core/commit/27f6149f330137bc1d6350271c246ebe0346122b) Release 1.5.1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-25 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -228,6 +228,7 @@ files:
228
228
  - lib/appium_lib_core/android/search_context.rb
229
229
  - lib/appium_lib_core/android/uiautomator1/bridge.rb
230
230
  - lib/appium_lib_core/android/uiautomator2/bridge.rb
231
+ - lib/appium_lib_core/android/uiautomator2/device.rb
231
232
  - lib/appium_lib_core/android_espresso.rb
232
233
  - lib/appium_lib_core/android_uiautomator2.rb
233
234
  - lib/appium_lib_core/common.rb
@@ -247,16 +248,17 @@ files:
247
248
  - lib/appium_lib_core/common/error.rb
248
249
  - lib/appium_lib_core/common/log.rb
249
250
  - lib/appium_lib_core/common/logger.rb
251
+ - lib/appium_lib_core/common/touch_action/multi_touch.rb
252
+ - lib/appium_lib_core/common/touch_action/touch_actions.rb
250
253
  - lib/appium_lib_core/common/wait.rb
251
254
  - lib/appium_lib_core/common/wait/timer.rb
252
255
  - lib/appium_lib_core/common/ws/websocket.rb
253
256
  - lib/appium_lib_core/device.rb
254
257
  - lib/appium_lib_core/device/app_state.rb
258
+ - lib/appium_lib_core/device/battery_status.rb
255
259
  - lib/appium_lib_core/device/clipboard_content_type.rb
256
260
  - lib/appium_lib_core/device/image_comparison.rb
257
- - lib/appium_lib_core/device/multi_touch.rb
258
261
  - lib/appium_lib_core/device/screen_record.rb
259
- - lib/appium_lib_core/device/touch_actions.rb
260
262
  - lib/appium_lib_core/driver.rb
261
263
  - lib/appium_lib_core/ios.rb
262
264
  - lib/appium_lib_core/ios/device.rb