appium_lib 11.1.0 → 12.0.0.rc3

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.
@@ -234,11 +234,11 @@ module Appium
234
234
 
235
235
  if class_name == '*'
236
236
  return "//*[contains(translate(@text,'#{value.upcase}', '#{value}'), '#{value}')" \
237
- " or contains(translate(@content-desc,'#{value.upcase}', '#{value}'), '#{value}')" + r_id + ']'
237
+ " or contains(translate(@content-desc,'#{value.upcase}', '#{value}'), '#{value}')" + r_id + ']'
238
238
  end
239
239
 
240
240
  "//#{class_name}[contains(translate(@text,'#{value.upcase}', '#{value}'), '#{value}')" \
241
- " or contains(translate(@content-desc,'#{value.upcase}', '#{value}'), '#{value}')" + r_id + ']'
241
+ " or contains(translate(@content-desc,'#{value.upcase}', '#{value}'), '#{value}')" + r_id + ']'
242
242
  end
243
243
 
244
244
  # Returns a string that matches the first element that contains value
@@ -98,10 +98,10 @@ module Appium
98
98
 
99
99
  if button_index && image_button_index
100
100
  "new UiSelector().className(#{BUTTON}).instance(#{button_index});" \
101
- "new UiSelector().className(#{IMAGE_BUTTON}).instance(#{image_button_index});"
101
+ "new UiSelector().className(#{IMAGE_BUTTON}).instance(#{image_button_index});"
102
102
  else
103
103
  "new UiSelector().className(#{BUTTON});" \
104
- "new UiSelector().className(#{IMAGE_BUTTON});"
104
+ "new UiSelector().className(#{IMAGE_BUTTON});"
105
105
  end
106
106
  end
107
107
 
@@ -56,12 +56,10 @@ module Appium
56
56
  rid = resource_id(text, "new UiSelector().resourceId(#{text})")
57
57
  args = rid.empty? ? ["new UiSelector().textContains(#{text})", "new UiSelector().descriptionContains(#{text})"] : [rid]
58
58
  args.each_with_index do |arg, index|
59
- begin
60
- elem = find_element :uiautomator, scroll_uiselector(arg, scrollable_index)
61
- return elem
62
- rescue StandardError => e
63
- raise e if index == args.size - 1
64
- end
59
+ elem = find_element :uiautomator, scroll_uiselector(arg, scrollable_index)
60
+ return elem
61
+ rescue StandardError => e
62
+ raise e if index == args.size - 1
65
63
  end
66
64
  end
67
65
 
@@ -74,12 +72,10 @@ module Appium
74
72
  rid = resource_id(text, "new UiSelector().resourceId(#{text})")
75
73
  args = rid.empty? ? ["new UiSelector().text(#{text})", "new UiSelector().description(#{text})"] : [rid]
76
74
  args.each_with_index do |arg, index|
77
- begin
78
- elem = find_element :uiautomator, scroll_uiselector(arg, scrollable_index)
79
- return elem
80
- rescue StandardError => e
81
- raise e if index == args.size - 1
82
- end
75
+ elem = find_element :uiautomator, scroll_uiselector(arg, scrollable_index)
76
+ return elem
77
+ rescue StandardError => e
78
+ raise e if index == args.size - 1
83
79
  end
84
80
  end
85
81
  end # module Android
@@ -25,19 +25,17 @@ module Appium
25
25
  w_s = window_rect
26
26
 
27
27
  (1..30).each do |_count|
28
- begin
29
- action
30
- .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number
31
- .pointer_down(:left)
32
- .move_to_location(0, w_s.height / 5)
33
- .release
34
- .perform
35
- sleep 1 # we must wait finish scrolling
28
+ action
29
+ .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number
30
+ .pointer_down(:left)
31
+ .move_to_location(0, w_s.height / 5)
32
+ .release
33
+ .perform
34
+ sleep 1 # we must wait finish scrolling
36
35
 
37
- return text(text)
38
- rescue StandardError => e
39
- err = e
40
- end
36
+ return text(text)
37
+ rescue StandardError => e
38
+ err = e
41
39
  end
42
40
 
43
41
  raise err
@@ -52,19 +50,17 @@ module Appium
52
50
  w_s = window_rect
53
51
 
54
52
  (1..30).each do |_count|
55
- begin
56
- action
57
- .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number
58
- .pointer_down(:left)
59
- .move_to_location(0, w_s.height / 5)
60
- .release
61
- .perform
62
- sleep 1 # we must wait finish scrolling
53
+ action
54
+ .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number
55
+ .pointer_down(:left)
56
+ .move_to_location(0, w_s.height / 5)
57
+ .release
58
+ .perform
59
+ sleep 1 # we must wait finish scrolling
63
60
 
64
- return text_exact(text)
65
- rescue StandardError => e
66
- err = e
67
- end
61
+ return text_exact(text)
62
+ rescue StandardError => e
63
+ err = e
68
64
  end
69
65
 
70
66
  raise err
@@ -101,10 +101,10 @@ module Appium
101
101
 
102
102
  if button_index && image_button_index
103
103
  "new UiSelector().className(#{::Appium::Android::Button}).instance(#{button_index});" \
104
- "new UiSelector().className(#{::Appium::Android::ImageButton}).instance(#{image_button_index});"
104
+ "new UiSelector().className(#{::Appium::Android::ImageButton}).instance(#{image_button_index});"
105
105
  else
106
106
  "new UiSelector().className(#{::Appium::Android::Button});" \
107
- "new UiSelector().className(#{::Appium::Android::ImageButton});"
107
+ "new UiSelector().className(#{::Appium::Android::ImageButton});"
108
108
  end
109
109
  end
110
110
 
@@ -156,18 +156,16 @@ module Appium
156
156
 
157
157
  target_modules.each do |const|
158
158
  # noinspection RubyResolve
159
- # rubocop:disable Style/MultilineIfModifier
160
159
  driver.public_methods(false).each do |m|
160
+ # override unless there's an existing method with matching arity
161
+ next if const.respond_to?(m) && const.method(m).arity == driver.method(m).arity
162
+
161
163
  const.send(:define_singleton_method, m) do |*args, &block|
162
- begin
163
- super(*args, &block) # promote.rb
164
- rescue NoMethodError, ArgumentError
165
- driver.send m, *args, &block if driver.respond_to?(m)
166
- end
167
- # override unless there's an existing method with matching arity
168
- end unless const.respond_to?(m) && const.method(m).arity == driver.method(m).arity
164
+ super(*args, &block) # promote.rb
165
+ rescue NoMethodError, ArgumentError
166
+ driver.send m, *args, &block if driver.respond_to?(m)
167
+ end
169
168
  end
170
- # rubocop:enable Style/MultilineIfModifier
171
169
  end
172
170
  end
173
171
 
@@ -210,23 +208,21 @@ module Appium
210
208
  end
211
209
 
212
210
  define_method method do |*args, &block|
213
- begin
214
- # Prefer existing method.
215
- # super will invoke method missing on driver
216
- super(*args, &block)
217
-
218
- # minitest also defines a name method,
219
- # so rescue argument error
220
- # and call the name method on $driver
221
- rescue NoMethodError, ArgumentError
222
- if args.size == 1 && args.first.is_a?(Hash)
223
- # To prevent warnings by keyword arguments (for Ruby 2.7 and 3)
224
- driver.send method, **args.first, &block if driver.respond_to?(method)
225
- else
226
- ::Appium::Logger.warn "Should fix this '#{args}' for Ruby 2.7 (and 3)" if args.first.is_a?(Hash)
227
-
228
- driver.send method, *args, &block if driver.respond_to?(method)
229
- end
211
+ # Prefer existing method.
212
+ # super will invoke method missing on driver
213
+ super(*args, &block)
214
+
215
+ # minitest also defines a name method,
216
+ # so rescue argument error
217
+ # and call the name method on $driver
218
+ rescue NoMethodError, ArgumentError
219
+ if args.size == 1 && args.first.is_a?(Hash)
220
+ # To prevent warnings by keyword arguments (for Ruby 2.7 and 3)
221
+ driver.send method, **args.first, &block if driver.respond_to?(method)
222
+ else
223
+ ::Appium::Logger.warn "Should fix this '#{args}' for Ruby 2.7 (and 3)" if args.first.is_a?(Hash)
224
+
225
+ driver.send method, *args, &block if driver.respond_to?(method)
230
226
  end
231
227
  end
232
228
  end
@@ -42,7 +42,7 @@ module Appium
42
42
  # wait_true(20) { button_exact('Back') }.click
43
43
  #
44
44
  def wait_true(opts = {})
45
- opts = opts.is_a?(Numeric) ? { timeout: opts } : opts
45
+ opts = { timeout: opts } if opts.is_a? Numeric
46
46
 
47
47
  if opts.is_a? Hash
48
48
  opts.empty? ? @core.wait_true { yield } : @core.wait_true(**opts) { yield }
@@ -71,8 +71,7 @@ module Appium
71
71
  # wait(20) { button_exact('Back') }.click
72
72
  #
73
73
  def wait(opts = {})
74
- opts = opts.is_a?(Numeric) ? { timeout: opts } : opts
75
-
74
+ opts = { timeout: opts } if opts.is_a? Numeric
76
75
  if opts.is_a? Hash
77
76
  opts.empty? ? @core.wait { yield } : @core.wait(**opts) { yield }
78
77
  else
@@ -151,18 +151,10 @@ module Appium
151
151
  # @param opts [Object] A hash containing various options.
152
152
  # @param global_driver [Bool] A bool require global driver before initialize.
153
153
  # @return [Driver]
154
- def initialize(opts = {}, global_driver = nil)
155
- # TODO: set `global_driver = false` by default in the future.
154
+ def initialize(opts = {}, global_driver = false)
156
155
  # Capybara can't put `global_driver` as the 2nd argument.
157
156
  global_driver = opts.delete :global_driver if global_driver.nil?
158
157
 
159
- if global_driver.nil?
160
- warn '[DEPRECATION] Appium::Driver.new(opts) will not generate global driver by default.' \
161
- 'If you would like to generate the global driver dy default, ' \
162
- 'please initialise driver with Appium::Driver.new(opts, true)'
163
- global_driver = true # if global_driver is nil, then global_driver must be default value.
164
- end
165
-
166
158
  $driver&.driver_quit if global_driver
167
159
 
168
160
  raise 'opts must be a hash' unless opts.is_a? Hash
@@ -325,27 +317,7 @@ module Appium
325
317
  !@core.automation_name.nil? && @core.automation_name == :xcuitest
326
318
  end
327
319
 
328
- # Get the dialect value whether current driver is OSS or W3C
329
- #
330
- # @return [:oss | :w3c]
331
- #
332
- # @example
333
- #
334
- # if dialect == :w3c
335
- # driver.action
336
- # .move_to_location(500, 500).pointer_down(:left)
337
- # .move_to_location(0, 700)
338
- # .release.perform
339
- # else
340
- # action = TouchAction.new(driver).press(x: 500, y: 500).move_to(500, 700).release
341
- # action.perform
342
- # end
343
- #
344
- def dialect
345
- @driver.dialect
346
- end
347
-
348
- # An entry point to chain W3C actions. Returns `TouchAction.new` if it works as MJSONWP instead of W3C action.
320
+ # An entry point to chain W3C actions
349
321
  # Read https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Base/Bridge/W3C#action-instance_method
350
322
  #
351
323
  # @return [TouchAction|Selenium::WebDriver::PointerActions]
@@ -356,12 +328,7 @@ module Appium
356
328
  # action.click(element).perform # The `click` is a part of `PointerActions`
357
329
  #
358
330
  def action
359
- if @driver.dialect != :w3c
360
- ::Appium::Logger.info('Calls TouchAction instead of W3C actions for MJSONWP module')
361
- TouchAction.new($driver || @driver)
362
- else
363
- @driver.action
364
- end
331
+ @driver.action
365
332
  end
366
333
 
367
334
  # Returns the server's version info
@@ -815,7 +782,9 @@ module Appium
815
782
  end
816
783
 
817
784
  def log_event=(log_event)
818
- raise ArgumentError('log_event should be Hash like { vendor: "appium", event: "funEvent"}') unless log_event.is_a?(Hash)
785
+ unless log_event.is_a?(Hash)
786
+ raise ::Appium::Core::Error::ArgumentError('log_event should be Hash like { vendor: "appium", event: "funEvent"}')
787
+ end
819
788
 
820
789
  @driver.logs.event vendor: log_event[:vendor], event: log_event[:event]
821
790
  end
@@ -24,7 +24,7 @@ module Appium
24
24
  # ```
25
25
  def swipe(direction:, element: nil)
26
26
  args = { direction: direction }
27
- args[:element] = element.ref if element
27
+ args[:element] = element.id if element
28
28
 
29
29
  @driver.execute_script 'mobile: swipe', args
30
30
  end
@@ -47,7 +47,7 @@ module Appium
47
47
  return 'Set "up", "down", "left" or "right" for :direction' unless %w(up down left right).include?(direction)
48
48
 
49
49
  args = { direction: direction }
50
- args[:element] = element.ref if element
50
+ args[:element] = element.id if element
51
51
  args[:distance] = distance if distance
52
52
  args[:name] = name if name
53
53
  args[:toVisible] = to_visible if to_visible
@@ -66,7 +66,7 @@ module Appium
66
66
  # ```
67
67
  def pinch(scale:, velocity: 1.0, element: nil)
68
68
  args = { scale: scale, velocity: velocity }
69
- args[:element] = element.ref if element
69
+ args[:element] = element.id if element
70
70
 
71
71
  @driver.execute_script 'mobile: pinch', args
72
72
  end
@@ -82,7 +82,7 @@ module Appium
82
82
  def double_tap(x: nil, y: nil, element: nil)
83
83
  return 'Set x, y or element' if (x.nil? || y.nil?) && element.nil?
84
84
 
85
- args = element.nil? ? { x: x, y: y } : { element: element.ref }
85
+ args = element.nil? ? { x: x, y: y } : { element: element.id }
86
86
  @driver.execute_script 'mobile: doubleTap', args
87
87
  end
88
88
 
@@ -99,7 +99,7 @@ module Appium
99
99
  def touch_and_hold(x: nil, y: nil, element: nil, duration: 1.0)
100
100
  return 'Set x, y or element' if (x.nil? || y.nil?) && element.nil?
101
101
 
102
- args = element.nil? ? { x: x, y: y } : { element: element.ref }
102
+ args = element.nil? ? { x: x, y: y } : { element: element.id }
103
103
  args[:duration] = duration
104
104
  @driver.execute_script 'mobile: touchAndHold', args
105
105
  end
@@ -110,7 +110,7 @@ module Appium
110
110
  # two_finger_tap element: find_element(:accessibility_id, "some item")
111
111
  # ```
112
112
  def two_finger_tap(element:)
113
- args = { element: element.ref }
113
+ args = { element: element.id }
114
114
  @driver.execute_script 'mobile: twoFingerTap', args
115
115
  end
116
116
 
@@ -126,7 +126,7 @@ module Appium
126
126
  # ```
127
127
  def one_finger_tap(x:, y:, element: nil)
128
128
  args = { x: x, y: y }
129
- args[:element] = element.ref if element
129
+ args[:element] = element.id if element
130
130
  @driver.execute_script 'mobile: tap', args
131
131
  end
132
132
 
@@ -146,7 +146,7 @@ module Appium
146
146
  # ```
147
147
  def drag_from_to_for_duration(from_x:, from_y:, to_x:, to_y:, duration: 1.0, element: nil)
148
148
  args = { fromX: from_x, fromY: from_y, toX: to_x, toY: to_y, duration: duration }
149
- args[:element] = element.ref if element
149
+ args[:element] = element.id if element
150
150
  @driver.execute_script 'mobile: dragFromToForDuration', args
151
151
  end
152
152
  # rubocop:enable Metrics/ParameterLists
@@ -164,7 +164,7 @@ module Appium
164
164
  def select_picker_wheel(element:, order:, offset: nil)
165
165
  return 'Set "next" or "previous" for :order' unless %w(next previous).include?(order)
166
166
 
167
- args = { element: element.ref, order: order }
167
+ args = { element: element.id, order: order }
168
168
  args[:offset] = offset if offset
169
169
  @driver.execute_script 'mobile: selectPickerWheelValue', args
170
170
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  module Appium
16
16
  # Version and Date are defined on the 'Appium' module, not 'Appium::Common'
17
- VERSION = '11.1.0' unless defined? ::Appium::VERSION
18
- DATE = '2020-12-29' unless defined? ::Appium::DATE
17
+ VERSION = '12.0.0.rc3' unless defined? ::Appium::VERSION
18
+ DATE = '2021-10-27' unless defined? ::Appium::DATE
19
19
  end
data/readme.md CHANGED
@@ -21,9 +21,11 @@ We can avoid the class driver with current `ruby_lib`, but if you'd like to impl
21
21
  # Setup
22
22
  ## Requirement
23
23
  - [Appium](https://github.com/appium/appium#requirements)
24
- - Ruby: 2.4+
24
+ - Ruby: 2.6+
25
25
 
26
26
  ### Ruby Lib and Appium
27
+
28
+ - Ruby library version over `12.0.0` is based on Selenium v4
27
29
  - Ruby library version over `9.8.0` requires Appium over `1.8`
28
30
  - Ruby library version under `9.7.5` can work with Appium under `1.7`
29
31
 
@@ -35,16 +37,9 @@ $ appium
35
37
  ```
36
38
 
37
39
  ## Install / Upgrade
38
- - Update rubygems and bundler
39
- ```bash
40
- $ gem update --system
41
- $ gem update bundler
42
- ```
43
40
 
44
- - Install the latest gem release
45
41
  ```bash
46
- gem uninstall -aIx appium_lib
47
- gem install --no-rdoc --no-ri appium_lib
42
+ gem install appium_lib
48
43
  ```
49
44
 
50
45
  ## [Sauce Labs env vars](https://github.com/appium/ruby_lib/blob/master/lib/appium_lib/sauce_labs.rb)
data/release_notes.md CHANGED
@@ -1,3 +1,10 @@
1
+ #### v11.2.0 2021-01-25
2
+
3
+ - [06f2e54](https://github.com/appium/ruby_lib/commit/06f2e54b4b55df25e624272b5a2cd7b23a000298) Release 11.2.0
4
+ - [8489c32](https://github.com/appium/ruby_lib/commit/8489c32dbb9c2b499af82e874aa532f2c9f63d8d) chore: Update rubocop requirement from = 1.8.0 to = 1.8.1 (#897)
5
+ - [eba6a68](https://github.com/appium/ruby_lib/commit/eba6a68b93f010101b3713fef162c23e6c75b330) chore: Update rubocop requirement from = 1.7.0 to = 1.8.0 (#896)
6
+
7
+
1
8
  #### v11.1.0 2020-12-29
2
9
 
3
10
  - [bc3da9b](https://github.com/appium/ruby_lib/commit/bc3da9bc1ee58d5e96811b72f3ed737ed0e9c401) Release 11.1.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.1.0
4
+ version: 12.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-29 00:00:00.000000000 Z
12
+ date: 2021-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appium_lib_core
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: '4.1'
20
+ version: 5.0.0.rc7
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: '4.1'
27
+ version: 5.0.0.rc7
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: nokogiri
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -49,16 +49,22 @@ dependencies:
49
49
  name: tomlrb
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
+ - - "<"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.0'
55
58
  type: :runtime
56
59
  prerelease: false
57
60
  version_requirements: !ruby/object:Gem::Requirement
58
61
  requirements:
59
- - - "~>"
62
+ - - ">="
60
63
  - !ruby/object:Gem::Version
61
64
  version: '1.1'
65
+ - - "<"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
62
68
  - !ruby/object:Gem::Dependency
63
69
  name: appium_thor
64
70
  requirement: !ruby/object:Gem::Requirement
@@ -85,14 +91,14 @@ dependencies:
85
91
  requirements:
86
92
  - - "~>"
87
93
  - !ruby/object:Gem::Version
88
- version: 1.3.0
94
+ version: 1.4.0
89
95
  type: :development
90
96
  prerelease: false
91
97
  version_requirements: !ruby/object:Gem::Requirement
92
98
  requirements:
93
99
  - - "~>"
94
100
  - !ruby/object:Gem::Version
95
- version: 1.3.0
101
+ version: 1.4.0
96
102
  - !ruby/object:Gem::Dependency
97
103
  name: hashdiff
98
104
  requirement: !ruby/object:Gem::Requirement
@@ -155,14 +161,14 @@ dependencies:
155
161
  requirements:
156
162
  - - '='
157
163
  - !ruby/object:Gem::Version
158
- version: 1.7.0
164
+ version: 1.22.2
159
165
  type: :development
160
166
  prerelease: false
161
167
  version_requirements: !ruby/object:Gem::Requirement
162
168
  requirements:
163
169
  - - '='
164
170
  - !ruby/object:Gem::Version
165
- version: 1.7.0
171
+ version: 1.22.2
166
172
  - !ruby/object:Gem::Dependency
167
173
  name: spec
168
174
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +214,7 @@ files:
208
214
  - ".azure-pipelines.yml"
209
215
  - ".github/ISSUE_TEMPLATE.md"
210
216
  - ".github/PULL_REQUEST_TEMPLATE.md"
217
+ - ".github/dependabot.yml"
211
218
  - ".github/workflows/rubocop.yml"
212
219
  - ".gitignore"
213
220
  - ".rubocop.yml"
@@ -298,14 +305,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
305
  requirements:
299
306
  - - ">="
300
307
  - !ruby/object:Gem::Version
301
- version: '2.4'
308
+ version: '2.6'
302
309
  required_rubygems_version: !ruby/object:Gem::Requirement
303
310
  requirements:
304
- - - ">="
311
+ - - ">"
305
312
  - !ruby/object:Gem::Version
306
- version: '0'
313
+ version: 1.3.1
307
314
  requirements: []
308
- rubygems_version: 3.2.0
315
+ rubygems_version: 3.2.15
309
316
  signing_key:
310
317
  specification_version: 4
311
318
  summary: Ruby library for Appium