testa_appium_driver 0.1.28 → 0.1.31

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
  SHA256:
3
- metadata.gz: 4bc06e0aef591d744a31c3c2a85860bb19cd1571039a358f9b00be5f56beef20
4
- data.tar.gz: 36ed9ac6468df4b6103bc7665197633c32456aa9d682fa593879912280e7fa43
3
+ metadata.gz: 65be3b1fd729bc6fae7bd56227ac9fd4e2167b0e132657ac19e40a0ad184adcf
4
+ data.tar.gz: bceb63d4ee18a492482d0b45ed41167a655cff3e565443fafeabf489672bcea2
5
5
  SHA512:
6
- metadata.gz: 915476c1654bc5cd33d1f80603260d8aa966822a19d0214a5f23c50cb796dea62ca2c534e30bb124158e7226426a609471121fbb92e8e1b402eacfcbd6394a6b
7
- data.tar.gz: 541f7b4399755f211ee781598d4abf8815192dcac36ab66326a2ed0535ad178ed87bf0586f04c7c9c7381a6b3f8f1ca76fd85400e59ce448dae65d9deec89ddb
6
+ metadata.gz: 2ac6d2ae6a120827a412f1ce018bef76d50080538607588cae5240db1cedc4d52599b13e6a4c1e7150f2d607495a76e890e0154a6abae147b501b6b22a69b5f0
7
+ data.tar.gz: 9dce5768f0f217de3ab7730a7b3d5645d66a5cbc0cb326f71c6df8cc9dca2d23351fb80661e52d6782d07f3e5f01fbfe21f8e56bf39f58ee954a73154e055f12
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
- gem "rubocop", "~> 1.26.0", require: false
12
+ gem "rubocop", require: false
13
13
  gem "rubocop-performance", require: false
@@ -7,8 +7,6 @@ module TestaAppiumDriver
7
7
  class Driver
8
8
  include ClassSelectors
9
9
 
10
-
11
-
12
10
  # executes shell command
13
11
  # @param [String] command Shell command name to execute for example echo or rm
14
12
  # @param [Array<String>] args Array of command arguments, example: ['-f', '/sdcard/my_file.txt']
@@ -16,33 +14,30 @@ module TestaAppiumDriver
16
14
  # @param [Boolean] includeStderr Whether to include stderr stream into the returned result.
17
15
  def shell(command, args: nil, timeout: nil, includeStderr: true)
18
16
  params = {
19
- command: command,
20
- includeStderr: includeStderr
17
+ command: command,
18
+ includeStderr: includeStderr,
21
19
  }
22
20
  params[:args] = args unless args.nil?
23
21
  params[:timeout] = timeout unless timeout.nil?
24
22
  @driver.execute_script("mobile: shell", params)
25
23
  end
26
24
 
27
-
28
25
  def scrollable
29
- locator = Locator.new(self, self, {single: true})
26
+ locator = Locator.new(self, self, { single: true })
30
27
  locator.xpath_selector = "//androidx.recyclerview.widget.RecyclerView|//android.widget.ScrollView|//android.widget.ListView|//android.widget.HorizontalScrollView"
31
28
  locator.ui_selector = "new UiSelector().scrollable(true).instance(0)"
32
29
  locator
33
30
  end
34
31
 
35
-
36
32
  def scrollables
37
- locator = Locator.new(self, self, {single: false})
33
+ locator = Locator.new(self, self, { single: false })
38
34
  locator.xpath_selector = "//androidx.recyclerview.widget.RecyclerView|//android.widget.ScrollView|//android.widget.ListView|//android.widget.HorizontalScrollView"
39
35
  locator.ui_selector = "new UiSelector().scrollable(true)"
40
36
  locator
41
37
  end
42
38
 
43
-
44
-
45
39
  private
40
+
46
41
  def handle_testa_opts
47
42
  if @testa_opts[:default_find_strategy].nil?
48
43
  @default_find_strategy = DEFAULT_ANDROID_FIND_STRATEGY
@@ -55,7 +50,6 @@ module TestaAppiumDriver
55
50
  end
56
51
  end
57
52
 
58
-
59
53
  if @testa_opts[:default_scroll_strategy].nil?
60
54
  @default_scroll_strategy = DEFAULT_ANDROID_SCROLL_STRATEGY
61
55
  else
@@ -68,4 +62,4 @@ module TestaAppiumDriver
68
62
  end
69
63
  end
70
64
  end
71
- end
65
+ end
@@ -67,13 +67,14 @@ module TestaAppiumDriver
67
67
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
68
68
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
69
69
  # @return [TestaAppiumDriver::Locator]
70
- def align(with = :top, top: nil, bottom: nil, right: nil, left: nil, scroll_to_find: false, max_attempts: 3)
70
+ def align(with = :top, top: nil, bottom: nil, right: nil, left: nil, scroll_to_find: false, max_attempts: 3, bounds_from_cache_element: true)
71
71
  deadzone = _process_deadzone(top, bottom, right, left)
72
72
  deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
73
73
  sa = ScrollActions.new(@scrollable_locator,
74
74
  locator: self,
75
75
  deadzone: deadzone,
76
- default_scroll_strategy: @default_scroll_strategy)
76
+ default_scroll_strategy: @default_scroll_strategy,
77
+ bounds_from_cache_element: bounds_from_cache_element)
77
78
  sa.align(with, scroll_to_find, max_attempts)
78
79
  self
79
80
  end
@@ -83,8 +84,8 @@ module TestaAppiumDriver
83
84
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
84
85
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
85
86
  # @return [TestaAppiumDriver::Locator]
86
- def align_top(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
87
- align(:top, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts)
87
+ def align_top(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
88
+ align(:top, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
88
89
  end
89
90
 
90
91
  # Aligns element on bottom of the scrollable container, if the element does not exists it will scroll to find it
@@ -92,8 +93,8 @@ module TestaAppiumDriver
92
93
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
93
94
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
94
95
  # @return [TestaAppiumDriver::Locator]
95
- def align_bottom(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
96
- align(:bottom, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts)
96
+ def align_bottom(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
97
+ align(:bottom, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
97
98
  end
98
99
 
99
100
  # Aligns element on left of the scrollable container, if the element does not exists it will scroll to find it
@@ -101,8 +102,8 @@ module TestaAppiumDriver
101
102
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
102
103
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
103
104
  # @return [TestaAppiumDriver::Locator]
104
- def align_left(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
105
- align(:left, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts)
105
+ def align_left(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
106
+ align(:left, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
106
107
  end
107
108
 
108
109
  # Aligns element on right of the scrollable container, if the element does not exists it will scroll to find it
@@ -110,8 +111,8 @@ module TestaAppiumDriver
110
111
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
111
112
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
112
113
  # @return [TestaAppiumDriver::Locator]
113
- def align_right(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
114
- align(:right, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts)
114
+ def align_right(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
115
+ align(:right, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
115
116
  end
116
117
 
117
118
  # Aligns element (by default) on top of the scrollable container, if the element does not exists it raise an exception
@@ -119,8 +120,8 @@ module TestaAppiumDriver
119
120
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
120
121
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
121
122
  # @return [TestaAppiumDriver::Locator]
122
- def align!(with = :top, top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
123
- align(with, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
123
+ def align!(with = :top, top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
124
+ align(with, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
124
125
  end
125
126
 
126
127
  # Aligns element on top of the scrollable container, if the element does not exists it raise an exception
@@ -128,8 +129,8 @@ module TestaAppiumDriver
128
129
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
129
130
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
130
131
  # @return [TestaAppiumDriver::Locator]
131
- def align_top!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
132
- align(:top, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
132
+ def align_top!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
133
+ align(:top, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
133
134
  end
134
135
 
135
136
  # Aligns element on bottom of the scrollable container, if the element does not exists it raise an exception
@@ -137,8 +138,8 @@ module TestaAppiumDriver
137
138
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
138
139
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
139
140
  # @return [TestaAppiumDriver::Locator]
140
- def align_bottom!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
141
- align(:bottom, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
141
+ def align_bottom!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
142
+ align(:bottom, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
142
143
  end
143
144
 
144
145
  # Aligns element on left of the scrollable container, if the element does not exists it raise an exception
@@ -146,8 +147,8 @@ module TestaAppiumDriver
146
147
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
147
148
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
148
149
  # @return [TestaAppiumDriver::Locator]
149
- def align_left!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
150
- align(:left, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
150
+ def align_left!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
151
+ align(:left, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
151
152
  end
152
153
 
153
154
  # Aligns element on right of the scrollable container, if the element does not exists it raise an exception
@@ -155,8 +156,8 @@ module TestaAppiumDriver
155
156
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
156
157
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
157
158
  # @return [TestaAppiumDriver::Locator]
158
- def align_right!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
159
- align(:right, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
159
+ def align_right!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3, bounds_from_cache_element: true)
160
+ align(:right, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts, bounds_from_cache_element: bounds_from_cache_element)
160
161
  end
161
162
 
162
163
  # First scrolls to the beginning of the scrollable container and then scrolls down until element is found or end is reached
@@ -186,7 +186,7 @@ module ::TestaAppiumDriver
186
186
  stale_retries = 0
187
187
  begin
188
188
  until is_aligned?(with, element) || timeout == max_attempts
189
- # $ctx.puts("align roudn: #{timeout}")
189
+ # $ctx.puts("align roudn: #{timeout}")
190
190
  w3c_attempt_align(with, speed_coef)
191
191
  timeout += 1
192
192
  end
@@ -194,12 +194,12 @@ module ::TestaAppiumDriver
194
194
  # if boundElementsByIndex is enabled, we can get stale element reference while doing scroll each
195
195
  stale_retries += 1
196
196
  sleep 0.2
197
- # $ctx.puts "Looking for #{@locator.xpath_selector}"
197
+ # $ctx.puts "Looking for #{@locator.xpath_selector}"
198
198
  element = @locator.execute if @locator.instance_of?(TestaAppiumDriver::Locator)
199
199
  retry if stale_retries < 4
200
200
  raise
201
201
  end
202
- # $ctx.puts("end align")
202
+ # $ctx.puts("end align")
203
203
  end
204
204
 
205
205
  def w3c_attempt_align(with, speed_coef)
@@ -240,10 +240,9 @@ module ::TestaAppiumDriver
240
240
  rounds = 0
241
241
  max_scrolls_reached = false
242
242
  end_of_scroll_reached = false
243
- # $ctx.puts("starting scroll to")
244
- until (@driver.android? && @locator.exists?) ||
245
- (@driver.ios? && @locator.exists? && @locator.in_viewport?) || end_of_scroll_reached
246
- # $ctx.puts("Scroll to round: #{rounds}")
243
+ # $ctx.puts("starting scroll to")
244
+ until (element_found = ((@driver.android? && @locator.exists?) || (@driver.ios? && @locator.exists? && @locator.in_viewport?))) || end_of_scroll_reached
245
+ # $ctx.puts("Scroll to round: #{rounds}")
247
246
  end_of_scroll_reached = is_end_of_scroll?
248
247
  case direction
249
248
  when :down
@@ -269,8 +268,8 @@ module ::TestaAppiumDriver
269
268
  max_scrolls_reached = true if rounds == @max_scrolls
270
269
  break if rounds == @max_scrolls
271
270
  end
272
- # $ctx.puts("end scroll to")
273
- raise Selenium::WebDriver::Error::NoSuchElementError if max_scrolls_reached || end_of_scroll_reached
271
+ # $ctx.puts("end scroll to")
272
+ raise Selenium::WebDriver::Error::NoSuchElementError if (max_scrolls_reached || end_of_scroll_reached) && !element_found
274
273
  end
275
274
 
276
275
  def w3c_scroll_to_start_or_end(type)
@@ -363,8 +362,8 @@ module ::TestaAppiumDriver
363
362
  f1.create_pointer_move(duration: overscroll_pause, x: x1, y: y1, origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
364
363
  end
365
364
  f1.create_pointer_up(:left)
366
- puts "Scroll execute[w3c_action]: #{type}: {x0: #{x0}, y0: #{y0}} => (duration: #{duration}) => {x1: #{x1}, y1: #{y1}}"
367
- # $ctx.puts "Scroll execute[w3c_action]: #{type}: {x0: #{x0}, y0: #{y0}} => (duration: #{duration}) => {x1: #{x1}, y1: #{y1}}"
365
+ # puts "Scroll execute[w3c_action]: #{type}: {x0: #{x0}, y0: #{y0}} => (duration: #{duration}) => {x1: #{x1}, y1: #{y1}}"
366
+ # $ctx.puts "Scroll execute[w3c_action]: #{type}: {x0: #{x0}, y0: #{y0}} => (duration: #{duration}) => {x1: #{x1}, y1: #{y1}}"
368
367
  @driver.perform_actions [f1]
369
368
  end
370
369
 
@@ -16,6 +16,7 @@ module ::TestaAppiumDriver
16
16
  # - deadzone - [Hash] that stores top, bottom, left and right deadzone values. If deadzone[:top] is 200 then 200px from top of the scrollable container will not be used for scrolling
17
17
  # - max_scrolls - [Integer] maximum number of scrolls before exception is thrown
18
18
  # - default_scroll_strategy - defines which scroll strategy will be used if a scroll action is valid for multiple strategies
19
+ # - bounds_from_cache_element - true by default, use the cached element to get element bounds
19
20
  def initialize(scrollable, params = {})
20
21
  @scrollable = scrollable
21
22
  @locator = params[:locator]
@@ -23,6 +24,9 @@ module ::TestaAppiumDriver
23
24
  @deadzone = params[:deadzone]
24
25
  @max_scrolls = params[:max_scrolls]
25
26
  @default_scroll_strategy = params[:default_scroll_strategy]
27
+ @bounds_from_cache_element = params[:bounds_from_cache_element]
28
+ @bounds_from_cache_element = true if @bounds_from_cache_element.nil?
29
+
26
30
  @driver = @locator.driver
27
31
 
28
32
  if @scrollable.nil?
@@ -201,7 +205,20 @@ module ::TestaAppiumDriver
201
205
  end
202
206
 
203
207
  def is_aligned?(with, element)
204
- align_bounds = @locator.bounds(force_cache_element: element)
208
+ if @bounds_from_cache_element
209
+ # in some cases, the cached element returns the same bounds, even though it was scrolled a split second ago
210
+ align_bounds = @locator.bounds(force_cache_element: element)
211
+ else
212
+ align_bounds = @locator.bounds
213
+ end
214
+
215
+ # $ctx.puts("Align bounds: ")
216
+ # $ctx.puts(align_bounds)
217
+ # $ctx.puts("Scrollable bounds: ")
218
+ # $ctx.puts(@bounds)
219
+
220
+ # $ctx.puts("Deadzone: ")
221
+ # $ctx.puts(@deadzone)
205
222
  case with
206
223
  when :top
207
224
  @align_offset = align_bounds.top_left.y - @bounds.top_left.y - @deadzone[:top]
@@ -312,7 +312,7 @@ module ::TestaAppiumDriver
312
312
  def ios?
313
313
  device == :ios
314
314
  end
315
-
315
+
316
316
  private
317
317
  def extend_for(device, automation_name)
318
318
  case device
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ #noinspection RubyResolve
4
+ require "testa_appium_driver"
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = ".rspec_status"
9
+
10
+ # Disable RSpec exposing methods globally on `Module` and `main`
11
+ config.disable_monkey_patching!
12
+
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = :expect
15
+ end
16
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe TestaAppiumDriver do
4
+ it "Android Test" do
5
+
6
+
7
+ @options = {
8
+ caps: {
9
+ :platformName => "Android",
10
+ :adbPort => 5037,
11
+ :remoteAdbHost => 'localhost',
12
+ :newCommandTimeout => 0, # no timeout when zero
13
+ :adbExecTimeout => 600000,
14
+ :appPackage => "ro.superbet.sport.stage",
15
+ :androidInstallTimeout => 600000,
16
+ :uiautomator2ServerLaunchTimeout => 600000,
17
+ :uiautomator2ServerInstallTimeout => 600000,
18
+ #waitForSelectorTimeout: 26,
19
+ :waitForIdleTimeout => 1,
20
+ :appWaitPackage => "ro.superbet.sport.stage",
21
+ :deviceName => "Phone",
22
+ :app => "/testa/hard_storage/project_files/2/apks/bc72173fd9b03e80c58161f2a881c1e679ce368ba9ca79855501597ce2e312ad.apk",
23
+ :noSign => true,
24
+ :udid => "228b371032057ece",
25
+ :automationName => "uiautomator2",
26
+ :systemPort => rand(7000..32000),
27
+ :noReset => true,
28
+ :fullReset => false,
29
+ # :noReset => false,
30
+ # :fullReset => true,
31
+ skipServerInstallation: true,
32
+ :enableMultiWindows => true, # enables appium to see some otherwise "hidden" elements
33
+ #:disableWindowAnimation => true,
34
+ autoGrantPermissions: true,
35
+ },
36
+ appium_lib: {
37
+ #:server_url => "http://localhost:4723/wd/hub/"
38
+ :server_url => "http://10.150.0.56:4723/wd/hub/"
39
+ },
40
+ testa_appium_driver: {
41
+ #default_find_strategy: "xpath",
42
+ #default_scroll_strategy: "w3c",
43
+ scroll_to_find: false
44
+ }
45
+ }
46
+
47
+
48
+ d = TestaAppiumDriver::Driver.new(@options)
49
+
50
+ # d.element(id: "analyticsPositiveView").click
51
+ # d.element(id: "startPlayingLogInView").click
52
+ #
53
+ # d.edit_texts[0].send_keys "testdevice1"
54
+ #
55
+ # d.edit_texts[1].send_keys "superbet1x2"
56
+ #
57
+ # puts "Buttons #{d.buttons(id: "buttonView").count}"
58
+ # d.button(id: "buttonView").click
59
+
60
+
61
+ puts "aaa"
62
+
63
+ drag_handle = d.frame_layout(id: "defaultBetSlipView").linear_layout.view
64
+ puts drag_handle.bounds
65
+ drag_handle.wait_until_exists.drag_up_by(1000)
66
+ sleep 1
67
+
68
+ scrollable = d.element(id: "betSlipFragmentHolder").recycler_view(id:"recyclerView")
69
+ scrollable.elements(id: "match_holder").parent.each_down do |m|
70
+ puts "1"
71
+ name1 = m.element(id: "match_team1Name").text
72
+ name2 = m.element(id: "match_team2Name").text
73
+ market = m.element(id: "betOfferName").text
74
+ puts "name: #{name1} - #{name2}, market_name: #{market}"
75
+ end
76
+
77
+
78
+
79
+
80
+ d.element(id: "buttonView").click
81
+
82
+ d.text_view(text: "Județ").scroll_to.click
83
+
84
+ puts d.text_view(text: "Bihor").exists?
85
+ d.recycler_view.wait_until_exists
86
+ puts d.element(id: "viewPager").execute.text_view(text: "#soccer").text
87
+ d.text_view(text: "#soccer").preceding_siblings[2]
88
+ d.text_view(text: "#soccer").preceding_siblings.each_with_index do |e, i|
89
+ puts e.class_name
90
+ end
91
+ puts "--------"
92
+ puts d.text_view(text: "#soccer").preceding_sibling.class_name
93
+
94
+ puts "=============="
95
+ puts d.text_view(text: "#soccer").following_sibling.className
96
+
97
+
98
+ d.text_view(text: "Super Extra").scroll_to
99
+ d.text_view(text: "Super Extra").siblings
100
+
101
+ puts d.element(id: "viewPager").parent.text_view.text
102
+ d.scrollable.scroll_left_to
103
+
104
+
105
+ puts d.element(id: "viewPager").list_view.element(id: "nameView").scroll_up_to.text
106
+
107
+
108
+ puts d.text_view(text: "#soccer").bounds
109
+
110
+ d.element(id: "viewPager").elements(id: "nameView").each do |e|
111
+ puts e.text
112
+ end
113
+
114
+
115
+ expect(TestaAppiumDriver::VERSION).not_to be nil
116
+ end
117
+
118
+
119
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe TestaAppiumDriver do
4
+ it "iOS Test" do
5
+ require 'em/pure_ruby'
6
+ require 'appium_lib_core'
7
+ require 'net/http'
8
+
9
+ udid = "d4b893ee622bf59795eeaa7d2c36bcca05fcccb1"
10
+
11
+ #testa sends ingredients for remote quamotion to get app
12
+ path = "project_files/2/apks/5df912ca31070c6d70104b997a611c58274f92a0af0f2436944fea3db1c10822.ipa"
13
+ ipa_url = "https://supertesta.com/ipas/#{path}"
14
+ ipa_name = File.basename(path)
15
+
16
+ #quamotion endpoint that can receive ipa url, and download it
17
+ url = "http://10.150.0.56:9494/receive_ipa?udid=#{udid}&ipa_url=#{ipa_url}&ipa_name=#{ipa_name}"
18
+ uri = URI.parse(url)
19
+ http = Net::HTTP.new(uri.host, uri.port)
20
+ request = Net::HTTP::Post.new(uri.request_uri)
21
+ res = http.request(request)
22
+ raise "copy opa res code not 200 : #{res.code}" unless res.code == "200"
23
+ ipa_remote_path = res.body
24
+
25
+
26
+ start_vnc_url = "http://10.150.0.56:9494/start_vnc_server?udid=#{udid}"
27
+ uri = URI("#{start_vnc_url}")
28
+ res = Net::HTTP.start(uri.host, uri.port, read_timeout: 129) do |http|
29
+ http.max_retries = 0 # Fix http retries
30
+ http.request(Net::HTTP::Post.new(uri))
31
+ end
32
+ urls = JSON.parse(res.body)
33
+ wda_url = URI("#{urls['wda_url']}")
34
+ wda_port = wda_url.port
35
+
36
+
37
+ @options = {
38
+ caps: {
39
+ :platformName => "iOS",
40
+ :newCommandTimeout => 0, # no timeout when zero
41
+ :platformVersion => "14.4",
42
+ :bundleId => "ro.superbet.sport.stage",
43
+ :waitForIdleTimeout => 3000,
44
+ :deviceName => 'iphone',
45
+ :app => ipa_remote_path,
46
+ :webDriverAgentUrl => "http://127.0.0.1:#{wda_port}",
47
+ :automationName => "XCUITest",
48
+ :noSign => true,
49
+ :udid => udid, # iPhone 7 black
50
+
51
+
52
+ :systemPort => rand(7000..32000),
53
+ :noReset => true,
54
+ :fullReset => false,
55
+ :enableMultiWindows => true, # enables appium to see some otherwise "hidden" elements
56
+ #:disableWindowAnimation => true,
57
+ autoGrantPermissions: true,
58
+ },
59
+ appium_lib: {
60
+ #:server_url => "http://localhost:4723/wd/hub/"
61
+ :server_url => "http://10.150.0.56:4725/wd/hub/"
62
+ },
63
+ testa_appium_driver: {
64
+ #default_find_strategy: "xpath",
65
+ #default_scroll_strategy: "w3c",
66
+ scroll_to_find: false
67
+ }
68
+ }
69
+
70
+
71
+ d = TestaAppiumDriver::Driver.new(@options)
72
+
73
+ # d.element(id: "analyticsPositiveView").click
74
+ # d.element(id: "startPlayingLogInView").click
75
+ #
76
+ # d.edit_texts[0].send_keys "testdevice1"
77
+ #
78
+ # d.edit_texts[1].send_keys "superbet1x2"
79
+ #
80
+ # puts "Buttons #{d.buttons(id: "buttonView").count}"
81
+ # d.button(id: "buttonView").click
82
+ #
83
+ # sleep 10
84
+
85
+
86
+ puts d.static_text(text: "#soccer").wait_until_exists.text
87
+ d.element(text: "Super Extra").scroll_to
88
+ puts d.static_text(text: "#soccer").class_name
89
+ puts d.static_text(text: "#soccer").parent.class_name
90
+
91
+ d.text_view(text: "#soccer").preceding_siblings.each_with_index do |e, i|
92
+ puts d.text_view(text: "#soccer").preceding_siblings[i].className
93
+ puts e.className
94
+ end
95
+ puts "--------"
96
+ puts d.text_view(text: "#soccer").preceding_sibling.className
97
+
98
+ puts "=============="
99
+ puts d.text_view(text: "#soccer").following_sibling.className
100
+
101
+
102
+ d.text_view(text: "Super Extra").siblings
103
+
104
+ puts d.element(id: "viewPager").parent.text_view.text
105
+ d.scrollable.scroll_left_to
106
+
107
+
108
+ puts d.element(id: "viewPager").list_view.element(id: "nameView").scroll_up_to.text
109
+
110
+
111
+ puts d.text_view(text: "#soccer").bounds
112
+
113
+ d.element(id: "viewPager").elements(id: "nameView").each do |e|
114
+ puts e.text
115
+ end
116
+
117
+
118
+ expect(TestaAppiumDriver::VERSION).not_to be nil
119
+ end
120
+
121
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testa_appium_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - karlo.razumovic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-06 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib_core
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
- - !ruby/object:Gem::Dependency
42
- name: rubocop
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 1.19.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 1.19.0
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '13.0'
69
41
  description: Testa appium driver is a wrapper around ruby_lib_core. It leverages all
70
42
  driver features and makes them simple and easy to use, significantly reduces the
71
43
  amount of code needed and enables you to define locators that can be reused
@@ -75,52 +47,50 @@ executables: []
75
47
  extensions: []
76
48
  extra_rdoc_files: []
77
49
  files:
78
- - ".gitattributes"
79
- - ".gitignore"
80
- - ".rspec"
81
- - ".rubocop.yml"
82
- - CHANGELOG.md
83
- - CODE_OF_CONDUCT.md
84
- - Gemfile
85
- - Gemfile.lock
86
- - LICENSE.txt
87
- - README.md
88
- - Rakefile
89
- - bin/console
90
- - bin/setup
91
- - lib/testa_appium_driver.rb
92
- - lib/testa_appium_driver/android/class_selectors.rb
93
- - lib/testa_appium_driver/android/driver.rb
94
- - lib/testa_appium_driver/android/locator.rb
95
- - lib/testa_appium_driver/android/locator/attributes.rb
96
- - lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb
97
- - lib/testa_appium_driver/android/selenium_element.rb
98
- - lib/testa_appium_driver/common/bounds.rb
99
- - lib/testa_appium_driver/common/constants.rb
100
- - lib/testa_appium_driver/common/exceptions/strategy_mix_exception.rb
101
- - lib/testa_appium_driver/common/helpers.rb
102
- - lib/testa_appium_driver/common/locator.rb
103
- - lib/testa_appium_driver/common/locator/scroll_actions.rb
104
- - lib/testa_appium_driver/common/scroll_actions.rb
105
- - lib/testa_appium_driver/common/scroll_actions/json_wire_scroll_actions.rb
106
- - lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb
107
- - lib/testa_appium_driver/common/selenium_element.rb
108
- - lib/testa_appium_driver/driver.rb
109
- - lib/testa_appium_driver/ios/driver.rb
110
- - lib/testa_appium_driver/ios/locator.rb
111
- - lib/testa_appium_driver/ios/locator/attributes.rb
112
- - lib/testa_appium_driver/ios/selenium_element.rb
113
- - lib/testa_appium_driver/ios/type_selectors.rb
114
- - testa_appium_driver.gemspec
50
+ - "./CHANGELOG.md"
51
+ - "./CODE_OF_CONDUCT.md"
52
+ - "./Gemfile"
53
+ - "./LICENSE.txt"
54
+ - "./README.md"
55
+ - "./Rakefile"
56
+ - "./bin/console"
57
+ - "./bin/setup"
58
+ - "./lib/testa_appium_driver.rb"
59
+ - "./lib/testa_appium_driver/android/class_selectors.rb"
60
+ - "./lib/testa_appium_driver/android/driver.rb"
61
+ - "./lib/testa_appium_driver/android/locator.rb"
62
+ - "./lib/testa_appium_driver/android/locator/attributes.rb"
63
+ - "./lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb"
64
+ - "./lib/testa_appium_driver/android/selenium_element.rb"
65
+ - "./lib/testa_appium_driver/common/bounds.rb"
66
+ - "./lib/testa_appium_driver/common/constants.rb"
67
+ - "./lib/testa_appium_driver/common/exceptions/strategy_mix_exception.rb"
68
+ - "./lib/testa_appium_driver/common/helpers.rb"
69
+ - "./lib/testa_appium_driver/common/locator.rb"
70
+ - "./lib/testa_appium_driver/common/locator/scroll_actions.rb"
71
+ - "./lib/testa_appium_driver/common/scroll_actions.rb"
72
+ - "./lib/testa_appium_driver/common/scroll_actions/json_wire_scroll_actions.rb"
73
+ - "./lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb"
74
+ - "./lib/testa_appium_driver/common/selenium_element.rb"
75
+ - "./lib/testa_appium_driver/driver.rb"
76
+ - "./lib/testa_appium_driver/ios/driver.rb"
77
+ - "./lib/testa_appium_driver/ios/locator.rb"
78
+ - "./lib/testa_appium_driver/ios/locator/attributes.rb"
79
+ - "./lib/testa_appium_driver/ios/selenium_element.rb"
80
+ - "./lib/testa_appium_driver/ios/type_selectors.rb"
81
+ - "./spec/spec_helper.rb"
82
+ - "./spec/testa_appium_driver_android_spec.rb"
83
+ - "./spec/testa_appium_driver_ios_spec.rb"
115
84
  homepage: https://github.com/Karazum/testa_appium_driver
116
85
  licenses:
117
86
  - MIT
118
87
  metadata:
88
+ rubygems_mfa_required: 'true'
119
89
  documentation_uri: https://www.rubydoc.info/gems/testa_appium_driver
120
90
  homepage_uri: https://github.com/Karazum/testa_appium_driver
121
91
  source_code_uri: https://github.com/Karazum/testa_appium_driver
122
92
  changelog_uri: https://github.com/Karazum/testa_appium_driver
123
- post_install_message:
93
+ post_install_message:
124
94
  rdoc_options: []
125
95
  require_paths:
126
96
  - lib
@@ -136,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
106
  version: '0'
137
107
  requirements: []
138
108
  rubygems_version: 3.1.6
139
- signing_key:
109
+ signing_key:
140
110
  specification_version: 4
141
111
  summary: Appium made easy
142
112
  test_files: []
data/.gitattributes DELETED
@@ -1,23 +0,0 @@
1
- # Set the default behavior, in case people don't have core.autocrlf set.
2
- * text=auto
3
-
4
- # Declare files that will always have LF line endings on checkout.
5
- *.rb text eol=lf
6
- *.yml text eol=lf
7
- *.sh text eol=lf
8
- *.Dockerfile eol=lf
9
- *.dockerfile eol=lf
10
- *.conf eol=lf
11
- *.ru eol=lf
12
- *.json eol=lf
13
- *.js eol=lf
14
- *.css eol=lf
15
- *.erb eol=lf
16
- *.html eol=lf
17
- *.map eol=lf
18
-
19
- # Denote all files that are truly binary and should not be modified.
20
- *.png binary
21
- *.jpg binary
22
- *.bin binary
23
- *.zip binary
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- /.idea/deployment.xml
14
- /.idea/workspace.xml
15
- /.idea/misc.xml
16
- testa_appium_driver-*.gem
17
- /appium-driver.iml
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,6 +0,0 @@
1
- # we have to have per project rubcop files (IDE limitation),
2
- # but we want only one config across all projects
3
- # you can override any global cops here, in this file
4
- inherit_from:
5
- - ../../.rubocop.yml
6
- - ../../.rubocop-performance.yml
data/Gemfile.lock DELETED
@@ -1,80 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- testa_appium_driver (0.1.28)
5
- appium_lib_core
6
- json (~> 2.3)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- appium_lib_core (5.2.2)
12
- faye-websocket (~> 0.11.0)
13
- selenium-webdriver (~> 4.2, < 4.4)
14
- ast (2.4.2)
15
- childprocess (4.1.0)
16
- diff-lcs (1.5.0)
17
- eventmachine (1.2.7)
18
- faye-websocket (0.11.2)
19
- eventmachine (>= 0.12.0)
20
- websocket-driver (>= 0.5.1)
21
- json (2.6.3)
22
- parallel (1.22.1)
23
- parser (3.1.2.0)
24
- ast (~> 2.4.1)
25
- rainbow (3.1.1)
26
- rake (13.0.6)
27
- regexp_parser (2.4.0)
28
- rexml (3.2.5)
29
- rspec (3.11.0)
30
- rspec-core (~> 3.11.0)
31
- rspec-expectations (~> 3.11.0)
32
- rspec-mocks (~> 3.11.0)
33
- rspec-core (3.11.0)
34
- rspec-support (~> 3.11.0)
35
- rspec-expectations (3.11.0)
36
- diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.11.0)
38
- rspec-mocks (3.11.1)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.11.0)
41
- rspec-support (3.11.0)
42
- rubocop (1.26.0)
43
- parallel (~> 1.10)
44
- parser (>= 3.1.0.0)
45
- rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.8, < 3.0)
47
- rexml
48
- rubocop-ast (>= 1.16.0, < 2.0)
49
- ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 3.0)
51
- rubocop-ast (1.18.0)
52
- parser (>= 3.1.1.0)
53
- rubocop-performance (1.15.0)
54
- rubocop (>= 1.7.0, < 2.0)
55
- rubocop-ast (>= 0.4.0)
56
- ruby-progressbar (1.11.0)
57
- rubyzip (2.3.2)
58
- selenium-webdriver (4.3.0)
59
- childprocess (>= 0.5, < 5.0)
60
- rexml (~> 3.2, >= 3.2.5)
61
- rubyzip (>= 1.2.2, < 3.0)
62
- websocket (~> 1.0)
63
- unicode-display_width (2.1.0)
64
- websocket (1.2.9)
65
- websocket-driver (0.7.5)
66
- websocket-extensions (>= 0.1.0)
67
- websocket-extensions (0.1.5)
68
-
69
- PLATFORMS
70
- ruby
71
-
72
- DEPENDENCIES
73
- rake (~> 13.0)
74
- rspec (~> 3.0)
75
- rubocop (~> 1.26.0)
76
- rubocop-performance
77
- testa_appium_driver!
78
-
79
- BUNDLED WITH
80
- 2.3.14
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "testa_appium_driver"
5
- spec.version = "0.1.28"
6
- spec.authors = ["karlo.razumovic"]
7
- spec.email = ["karlo.razumovic@gmail.com"]
8
-
9
- spec.summary = "Appium made easy"
10
- spec.description = "Testa appium driver is a wrapper around ruby_lib_core. It leverages all driver features and makes them simple and easy to use, significantly reduces the amount of code needed and enables you to define locators that can be reused"
11
- spec.homepage = "https://github.com/Karazum/testa_appium_driver"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = ">= 2.7.6"
14
-
15
- #spec.metadata["allowed_push_host"] = "Set to 'https://mygemserver.com'"
16
-
17
- spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/testa_appium_driver"
18
- spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = "https://github.com/Karazum/testa_appium_driver"
20
- spec.metadata["changelog_uri"] = "https://github.com/Karazum/testa_appium_driver"
21
-
22
- # this can be optimized
23
- # spec.files = Dir["#{File.dirname(__FILE__)}/*"]
24
-
25
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
- end
28
-
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- spec.add_runtime_dependency "appium_lib_core"
34
- spec.add_runtime_dependency "json", ["~> 2.3"]
35
-
36
- spec.add_development_dependency "rubocop", ["= 1.19.0"]
37
- spec.add_development_dependency "rake", ["~> 13.0"]
38
-
39
- # For more information and examples about making a new gem, checkout our
40
- # guide at: https://bundler.io/guides/creating_gem.html
41
- end