appium_lib_core 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/CHANGELOG.md +11 -0
  4. data/lib/appium_lib_core/android/device/clipboard.rb +4 -4
  5. data/lib/appium_lib_core/android/device/screen.rb +1 -1
  6. data/lib/appium_lib_core/android/uiautomator2/device/battery.rb +2 -2
  7. data/lib/appium_lib_core/common/base.rb +17 -0
  8. data/lib/appium_lib_core/common/base/bridge.rb +1 -0
  9. data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +15 -0
  10. data/lib/appium_lib_core/common/base/bridge/w3c.rb +19 -0
  11. data/lib/appium_lib_core/common/base/driver.rb +599 -1
  12. data/lib/appium_lib_core/common/base/screenshot.rb +18 -0
  13. data/lib/appium_lib_core/common/device/app_management.rb +87 -0
  14. data/lib/appium_lib_core/common/device/app_state.rb +30 -0
  15. data/lib/appium_lib_core/common/device/battery_status.rb +25 -0
  16. data/lib/appium_lib_core/common/device/clipboard_content_type.rb +11 -0
  17. data/lib/appium_lib_core/common/device/context.rb +38 -0
  18. data/lib/appium_lib_core/common/device/device.rb +19 -0
  19. data/lib/appium_lib_core/common/device/device_lock.rb +22 -0
  20. data/lib/appium_lib_core/common/device/file_management.rb +26 -0
  21. data/lib/appium_lib_core/common/device/image_comparison.rb +168 -0
  22. data/lib/appium_lib_core/common/device/ime_actions.rb +29 -0
  23. data/lib/appium_lib_core/common/device/keyboard.rb +22 -0
  24. data/lib/appium_lib_core/common/device/keyevent.rb +38 -0
  25. data/lib/appium_lib_core/common/device/screen_record.rb +54 -0
  26. data/lib/appium_lib_core/common/device/setting.rb +17 -0
  27. data/lib/appium_lib_core/common/device/touch_actions.rb +21 -0
  28. data/lib/appium_lib_core/common/device/value.rb +19 -0
  29. data/lib/appium_lib_core/device.rb +24 -547
  30. data/lib/appium_lib_core/driver.rb +14 -9
  31. data/lib/appium_lib_core/element/image.rb +1 -1
  32. data/lib/appium_lib_core/ios/device/clipboard.rb +4 -4
  33. data/lib/appium_lib_core/ios/xcuitest/device/battery.rb +2 -2
  34. data/lib/appium_lib_core/ios/xcuitest/device/performance.rb +1 -3
  35. data/lib/appium_lib_core/ios/xcuitest/device/screen.rb +1 -1
  36. data/lib/appium_lib_core/ios_xcuitest.rb +0 -2
  37. data/lib/appium_lib_core/version.rb +2 -2
  38. data/release_notes.md +10 -0
  39. metadata +18 -17
  40. data/lib/appium_lib_core/device/app_management.rb +0 -113
  41. data/lib/appium_lib_core/device/app_state.rb +0 -32
  42. data/lib/appium_lib_core/device/battery_status.rb +0 -23
  43. data/lib/appium_lib_core/device/clipboard_content_type.rb +0 -9
  44. data/lib/appium_lib_core/device/context.rb +0 -48
  45. data/lib/appium_lib_core/device/device_lock.rb +0 -28
  46. data/lib/appium_lib_core/device/file_management.rb +0 -32
  47. data/lib/appium_lib_core/device/image_comparison.rb +0 -178
  48. data/lib/appium_lib_core/device/ime_actions.rb +0 -43
  49. data/lib/appium_lib_core/device/keyboard.rb +0 -26
  50. data/lib/appium_lib_core/device/keyevent.rb +0 -44
  51. data/lib/appium_lib_core/device/screen_record.rb +0 -56
  52. data/lib/appium_lib_core/device/setting.rb +0 -21
  53. data/lib/appium_lib_core/device/touch_actions.rb +0 -22
  54. data/lib/appium_lib_core/device/value.rb +0 -23
@@ -163,15 +163,9 @@ module Appium
163
163
  http_client_ops: { http_client: nil, open_timeout: 999_999, read_timeout: 999_999 })
164
164
  server_url ||= "http://127.0.0.1:#{@port}/wd/hub"
165
165
 
166
- # open_timeout and read_timeout are explicit wait.
167
- open_timeout = http_client_ops.delete(:open_timeout)
168
- read_timeout = http_client_ops.delete(:read_timeout)
169
-
170
- http_client = http_client_ops.delete(:http_client)
171
- @http_client ||= http_client ? http_client : Appium::Core::Base::Http::Default.new
172
-
173
- @http_client.open_timeout = open_timeout if open_timeout
174
- @http_client.read_timeout = read_timeout if read_timeout
166
+ create_http_client http_client: http_client_ops.delete(:http_client),
167
+ open_timeout: http_client_ops.delete(:open_timeout),
168
+ read_timeout: http_client_ops.delete(:read_timeout)
175
169
 
176
170
  begin
177
171
  # included https://github.com/SeleniumHQ/selenium/blob/43f8b3f66e7e01124eff6a5805269ee441f65707/rb/lib/selenium/webdriver/remote/driver.rb#L29
@@ -197,6 +191,14 @@ module Appium
197
191
 
198
192
  private
199
193
 
194
+ def create_http_client(http_client: nil, open_timeout: nil, read_timeout: nil)
195
+ @http_client ||= http_client ? http_client : Appium::Core::Base::Http::Default.new
196
+
197
+ # open_timeout and read_timeout are explicit wait.
198
+ @http_client.open_timeout = open_timeout if open_timeout
199
+ @http_client.read_timeout = read_timeout if read_timeout
200
+ end
201
+
200
202
  # Ignore setting default wait if the target driver has no implementation
201
203
  def set_implicit_wait_by_default(wait)
202
204
  @driver.manage.timeouts.implicit_wait = wait
@@ -317,6 +319,9 @@ module Appium
317
319
  when :windows
318
320
  # no windows specific extentions
319
321
  Appium::Logger.debug('windows')
322
+ when :tizen
323
+ # no tizen specific extentions
324
+ Appium::Logger.debug('tizen')
320
325
  else
321
326
  Appium::Logger.warn('no device matched')
322
327
  end
@@ -16,7 +16,7 @@ module Appium
16
16
  #
17
17
  attr_reader :visual
18
18
 
19
- def initialize(bridge, x, y, width, height, visual = nil) # rubocop:disable Metrics/ParameterLists
19
+ def initialize(bridge, x, y, width, height, visual = nil)
20
20
  @bridge = bridge
21
21
  @visual = visual
22
22
 
@@ -8,8 +8,8 @@ module Appium
8
8
  def self.add_methods
9
9
  ::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
10
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}"
11
+ unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
12
+ raise "content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
13
13
  end
14
14
 
15
15
  params = { contentType: content_type }
@@ -21,8 +21,8 @@ module Appium
21
21
 
22
22
  ::Appium::Core::Device.add_endpoint_method(:set_clipboard) do
23
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}"
24
+ unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
25
+ raise "content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
26
26
  end
27
27
 
28
28
  params = {
@@ -11,10 +11,10 @@ module Appium
11
11
 
12
12
  state = case response['state']
13
13
  when 1, 2, 3
14
- ::Appium::Core::Device::BatteryStatus::IOS[response['state']]
14
+ ::Appium::Core::Base::Device::BatteryStatus::IOS[response['state']]
15
15
  else
16
16
  ::Appium::Logger.warn("The state is unknown or undefined: #{response['state']}")
17
- ::Appium::Core::Device::BatteryStatus::IOS[0] # :unknown
17
+ ::Appium::Core::Base::Device::BatteryStatus::IOS[0] # :unknown
18
18
  end
19
19
  { state: state, level: response['level'] }
20
20
  end
@@ -17,10 +17,9 @@ module Appium
17
17
  end
18
18
 
19
19
  ::Appium::Core::Device.add_endpoint_method(:get_performance_record) do
20
- # rubocop:disable Metrics/ParameterLists
21
20
  def get_performance_record(save_file_path: './performance', profile_name: 'Activity Monitor',
22
21
  remote_path: nil, user: nil, pass: nil, method: 'PUT')
23
- option = ::Appium::Core::Device::ScreenRecord.new(
22
+ option = ::Appium::Core::Base::Device::ScreenRecord.new(
24
23
  remote_path: remote_path, user: user, pass: pass, method: method
25
24
  ).upload_option
26
25
 
@@ -29,7 +28,6 @@ module Appium
29
28
 
30
29
  File.open("#{save_file_path}.zip", 'wb') { |f| f << result.unpack('m')[0] }
31
30
  end
32
- # rubocop:enable Metrics/ParameterLists
33
31
  end
34
32
  end
35
33
  end # module Performance
@@ -9,7 +9,7 @@ module Appium
9
9
  # rubocop:disable Metrics/ParameterLists
10
10
  def start_recording_screen(remote_path: nil, user: nil, pass: nil, method: nil, force_restart: nil,
11
11
  video_type: 'mp4', time_limit: '180', video_quality: 'medium')
12
- option = ::Appium::Core::Device::ScreenRecord.new(
12
+ option = ::Appium::Core::Base::Device::ScreenRecord.new(
13
13
  remote_path: remote_path, user: user, pass: pass, method: method, force_restart: force_restart
14
14
  ).upload_option
15
15
 
@@ -5,5 +5,3 @@ 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.7.2'.freeze unless defined? ::Appium::Core::VERSION
4
- DATE = '2018-06-23'.freeze unless defined? ::Appium::Core::DATE
3
+ VERSION = '1.8.0'.freeze unless defined? ::Appium::Core::VERSION
4
+ DATE = '2018-07-07'.freeze unless defined? ::Appium::Core::DATE
5
5
  end
6
6
  end
data/release_notes.md CHANGED
@@ -1,3 +1,13 @@
1
+ #### v1.8.0 2018-07-07
2
+
3
+ - [77350e6](https://github.com/appium/ruby_lib_core/commit/77350e6a23b91c84f446e1637a748ff6feb01ded) Release 1.8.0
4
+ - [2162056](https://github.com/appium/ruby_lib_core/commit/21620568f14ed4537b43c29e2b28026795e30617) Remove dynamic method definitions (#103)
5
+ - [a2e89bf](https://github.com/appium/ruby_lib_core/commit/a2e89bfb9d596e96bd27501a290ad0a2ff3528d4) extract create http client
6
+ - [fb9d5e5](https://github.com/appium/ruby_lib_core/commit/fb9d5e5728745bc6a13434d9a7cedb88d08a7b8e) Add tizen (#100)
7
+ - [0ecc90b](https://github.com/appium/ruby_lib_core/commit/0ecc90b449a3d841402fe731add8cbe2e530d325) add changelog about find_element/s_by_image
8
+ - [a08c7c7](https://github.com/appium/ruby_lib_core/commit/a08c7c769d12316f3a410b28f93799682a111ed8) update docstring for find_elements_by_image
9
+
10
+
1
11
  #### v1.7.2 2018-06-23
2
12
 
3
13
  - [72bbc01](https://github.com/appium/ruby_lib_core/commit/72bbc01dc69579c5b7dea43b6ec01fee37299ebe) Release 1.7.2
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.7.2
4
+ version: 1.8.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-06-23 00:00:00.000000000 Z
11
+ date: 2018-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -251,6 +251,22 @@ files:
251
251
  - lib/appium_lib_core/common/command/common.rb
252
252
  - lib/appium_lib_core/common/command/mjsonwp.rb
253
253
  - lib/appium_lib_core/common/command/w3c.rb
254
+ - lib/appium_lib_core/common/device/app_management.rb
255
+ - lib/appium_lib_core/common/device/app_state.rb
256
+ - lib/appium_lib_core/common/device/battery_status.rb
257
+ - lib/appium_lib_core/common/device/clipboard_content_type.rb
258
+ - lib/appium_lib_core/common/device/context.rb
259
+ - lib/appium_lib_core/common/device/device.rb
260
+ - lib/appium_lib_core/common/device/device_lock.rb
261
+ - lib/appium_lib_core/common/device/file_management.rb
262
+ - lib/appium_lib_core/common/device/image_comparison.rb
263
+ - lib/appium_lib_core/common/device/ime_actions.rb
264
+ - lib/appium_lib_core/common/device/keyboard.rb
265
+ - lib/appium_lib_core/common/device/keyevent.rb
266
+ - lib/appium_lib_core/common/device/screen_record.rb
267
+ - lib/appium_lib_core/common/device/setting.rb
268
+ - lib/appium_lib_core/common/device/touch_actions.rb
269
+ - lib/appium_lib_core/common/device/value.rb
254
270
  - lib/appium_lib_core/common/error.rb
255
271
  - lib/appium_lib_core/common/log.rb
256
272
  - lib/appium_lib_core/common/logger.rb
@@ -260,21 +276,6 @@ files:
260
276
  - lib/appium_lib_core/common/wait/timer.rb
261
277
  - lib/appium_lib_core/common/ws/websocket.rb
262
278
  - lib/appium_lib_core/device.rb
263
- - lib/appium_lib_core/device/app_management.rb
264
- - lib/appium_lib_core/device/app_state.rb
265
- - lib/appium_lib_core/device/battery_status.rb
266
- - lib/appium_lib_core/device/clipboard_content_type.rb
267
- - lib/appium_lib_core/device/context.rb
268
- - lib/appium_lib_core/device/device_lock.rb
269
- - lib/appium_lib_core/device/file_management.rb
270
- - lib/appium_lib_core/device/image_comparison.rb
271
- - lib/appium_lib_core/device/ime_actions.rb
272
- - lib/appium_lib_core/device/keyboard.rb
273
- - lib/appium_lib_core/device/keyevent.rb
274
- - lib/appium_lib_core/device/screen_record.rb
275
- - lib/appium_lib_core/device/setting.rb
276
- - lib/appium_lib_core/device/touch_actions.rb
277
- - lib/appium_lib_core/device/value.rb
278
279
  - lib/appium_lib_core/driver.rb
279
280
  - lib/appium_lib_core/element/image.rb
280
281
  - lib/appium_lib_core/ios.rb
@@ -1,113 +0,0 @@
1
- module Appium
2
- module Core
3
- module Device
4
- module AppManagement
5
- def self.add_methods # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
6
- ::Appium::Core::Device.add_endpoint_method(:launch_app) do
7
- def launch_app
8
- execute :launch_app
9
- end
10
- end
11
-
12
- ::Appium::Core::Device.add_endpoint_method(:close_app) do
13
- def close_app
14
- execute :close_app
15
- end
16
- end
17
-
18
- ::Appium::Core::Device.add_endpoint_method(:close_app) do
19
- def close_app
20
- execute :close_app
21
- end
22
- end
23
-
24
- ::Appium::Core::Device.add_endpoint_method(:reset) do
25
- def reset
26
- execute :reset
27
- end
28
- end
29
-
30
- ::Appium::Core::Device.add_endpoint_method(:app_strings) do
31
- def app_strings(language = nil)
32
- opts = language ? { language: language } : {}
33
- execute :app_strings, {}, opts
34
- end
35
- end
36
-
37
- ::Appium::Core::Device.add_endpoint_method(:background_app) do
38
- def background_app(duration = 0)
39
- execute :background_app, {}, seconds: duration
40
- end
41
- end
42
-
43
- ::Appium::Core::Device.add_endpoint_method(:install_app) do
44
- def install_app(path, # rubocop:disable Metrics/ParameterLists
45
- replace: nil,
46
- timeout: nil,
47
- allow_test_packages: nil,
48
- use_sdcard: nil,
49
- grant_permissions: nil)
50
- args = { appPath: path }
51
-
52
- args[:options] = {} unless options?(replace, timeout, allow_test_packages, use_sdcard, grant_permissions)
53
-
54
- args[:options][:replace] = replace unless replace.nil?
55
- args[:options][:timeout] = timeout unless timeout.nil?
56
- args[:options][:allowTestPackages] = allow_test_packages unless allow_test_packages.nil?
57
- args[:options][:useSdcard] = use_sdcard unless use_sdcard.nil?
58
- args[:options][:grantPermissions] = grant_permissions unless grant_permissions.nil?
59
-
60
- execute :install_app, {}, args
61
- end
62
-
63
- private
64
-
65
- def options?(replace, timeout, allow_test_packages, use_sdcard, grant_permissions)
66
- replace.nil? || timeout.nil? || allow_test_packages.nil? || use_sdcard.nil? || grant_permissions.nil?
67
- end
68
- end
69
-
70
- ::Appium::Core::Device.add_endpoint_method(:remove_app) do
71
- def remove_app(id, keep_data: nil, timeout: nil)
72
- # required: [['appId'], ['bundleId']]
73
- args = { appId: id }
74
-
75
- args[:options] = {} unless keep_data.nil? || timeout.nil?
76
- args[:options][:keepData] = keep_data unless keep_data.nil?
77
- args[:options][:timeout] = timeout unless timeout.nil?
78
-
79
- execute :remove_app, {}, args
80
- end
81
- end
82
-
83
- ::Appium::Core::Device.add_endpoint_method(:app_installed?) do
84
- def app_installed?(app_id)
85
- # required: [['appId'], ['bundleId']]
86
- execute :app_installed?, {}, bundleId: app_id
87
- end
88
- end
89
-
90
- ::Appium::Core::Device.add_endpoint_method(:activate_app) do
91
- def activate_app(app_id)
92
- # required: [['appId'], ['bundleId']]
93
- execute :activate_app, {}, bundleId: app_id
94
- end
95
- end
96
-
97
- ::Appium::Core::Device.add_endpoint_method(:terminate_app) do
98
- def terminate_app(app_id, timeout: nil)
99
- # required: [['appId'], ['bundleId']]
100
- #
101
- args = { appId: app_id }
102
-
103
- args[:options] = {} unless timeout.nil?
104
- args[:options][:timeout] = timeout unless timeout.nil?
105
-
106
- execute :terminate_app, {}, args
107
- end
108
- end
109
- end
110
- end # module AppManagement
111
- end # module Device
112
- end # module Core
113
- end # module Appium
@@ -1,32 +0,0 @@
1
- module Appium
2
- module Core
3
- module Device
4
- module AppState
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
12
-
13
- def self.add_methods
14
- ::Appium::Core::Device.add_endpoint_method(:app_state) do
15
- def app_state(app_id)
16
- # required: [['appId'], ['bundleId']]
17
- response = execute :app_state, {}, appId: app_id
18
-
19
- case response
20
- when 0, 1, 2, 3, 4
21
- ::Appium::Core::Device::AppState::STATUS[response]
22
- else
23
- ::Appium::Logger.debug("Unexpected status in app_state: #{response}")
24
- response
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,23 +0,0 @@
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
@@ -1,9 +0,0 @@
1
- module Appium
2
- module Core
3
- module Device
4
- module Clipboard
5
- CONTENT_TYPE = [:plaintext, :image, :url].freeze
6
- end
7
- end
8
- end
9
- end
@@ -1,48 +0,0 @@
1
- module Appium
2
- module Core
3
- module Device
4
- module Context
5
- def self.add_methods
6
- ::Appium::Core::Device.add_endpoint_method(:within_context) do
7
- def within_context(context)
8
- existing_context = current_context
9
- set_context context
10
- if block_given?
11
- result = yield
12
- set_context existing_context
13
- result
14
- else
15
- set_context existing_context
16
- end
17
- end
18
- end
19
-
20
- ::Appium::Core::Device.add_endpoint_method(:switch_to_default_context) do
21
- def switch_to_default_context
22
- set_context nil
23
- end
24
- end
25
-
26
- ::Appium::Core::Device.add_endpoint_method(:current_context) do
27
- def current_context
28
- execute :current_context
29
- end
30
- end
31
-
32
- ::Appium::Core::Device.add_endpoint_method(:available_contexts) do
33
- def available_contexts
34
- # return empty array instead of nil on failure
35
- execute(:available_contexts, {}) || []
36
- end
37
- end
38
-
39
- ::Appium::Core::Device.add_endpoint_method(:set_context) do
40
- def set_context(context = null)
41
- execute :set_context, {}, name: context
42
- end
43
- end
44
- end
45
- end # module ImeActions
46
- end # module Device
47
- end # module Core
48
- end # module Appium