selenium-cucumber 2.1.4 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/generate.rb +19 -20
- data/bin/helper.rb +50 -50
- data/bin/selenium-cucumber +29 -30
- data/doc/canned_steps.md +656 -656
- data/doc/installation.md +16 -16
- data/doc/selenium-cucumber-API.md +120 -120
- data/doc/selenium-cucumber-help.md +18 -18
- data/features-skeleton/my_first.feature +5 -5
- data/features-skeleton/step_definitions/custom_steps.rb +4 -4
- data/features-skeleton/support/env.rb +51 -51
- data/features-skeleton/support/hooks.rb +47 -38
- data/lib/selenium-cucumber.rb +1 -1
- data/lib/selenium-cucumber/assertion_steps.rb +89 -89
- data/lib/selenium-cucumber/click_elements_steps.rb +36 -36
- data/lib/selenium-cucumber/configuration_steps.rb +6 -6
- data/lib/selenium-cucumber/input_steps.rb +69 -69
- data/lib/selenium-cucumber/javascript_handling_steps.rb +9 -9
- data/lib/selenium-cucumber/methods/assertion_methods.rb +295 -344
- data/lib/selenium-cucumber/methods/click_elements_methods.rb +23 -23
- data/lib/selenium-cucumber/methods/configuration_methods.rb +35 -35
- data/lib/selenium-cucumber/methods/error_handling_methods.rb +86 -86
- data/lib/selenium-cucumber/methods/input_methods.rb +67 -67
- data/lib/selenium-cucumber/methods/javascript_handling_methods.rb +9 -9
- data/lib/selenium-cucumber/methods/misc_methods.rb +34 -34
- data/lib/selenium-cucumber/methods/mobile_methods.rb +241 -241
- data/lib/selenium-cucumber/methods/navigate_methods.rb +165 -165
- data/lib/selenium-cucumber/methods/progress_methods.rb +15 -15
- data/lib/selenium-cucumber/methods/required_files.rb +10 -10
- data/lib/selenium-cucumber/methods/screenshot_methods.rb +6 -6
- data/lib/selenium-cucumber/mobile_steps.rb +99 -99
- data/lib/selenium-cucumber/navigation_steps.rb +105 -105
- data/lib/selenium-cucumber/progress_steps.rb +18 -18
- data/lib/selenium-cucumber/screenshot_steps.rb +5 -5
- data/lib/selenium-cucumber/version.rb +5 -5
- metadata +69 -91
- data/example/android/android_app/HinduCalendar.zip +0 -0
- data/example/android/android_app/HinduCalendar/HinduCalendar.apk +0 -0
- data/example/android/android_app/HinduCalendar/README.md +0 -19
- data/example/android/android_app/HinduCalendar/Results.html +0 -472
- data/example/android/android_app/HinduCalendar/features/01_HC_homepage_menu_validation.feature +0 -36
- data/example/android/android_app/HinduCalendar/features/02_HC_homepage_menu_navigation.feature +0 -71
- data/example/android/android_app/HinduCalendar/features/03_HC_Create_Save_View_Delete_Kundali.feature +0 -63
- data/example/android/android_app/HinduCalendar/features/actual_images/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/expected_images/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/image_difference/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/my_first.feature +0 -1
- data/example/android/android_app/HinduCalendar/features/screenshots/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/step_definitions/01_HC_homepage_menu_validation.rb +0 -81
- data/example/android/android_app/HinduCalendar/features/step_definitions/02_HC_homepage_menu_navigation.rb +0 -132
- data/example/android/android_app/HinduCalendar/features/step_definitions/03_HC_Create_Save_View_Delete_Kundali.rb +0 -413
- data/example/android/android_app/HinduCalendar/features/step_definitions/custom_steps.rb +0 -5
- data/example/android/android_app/HinduCalendar/features/support/env.rb +0 -51
- data/example/android/android_app/HinduCalendar/features/support/hooks.rb +0 -38
- data/example/android/android_app/android_app_calculator.zip +0 -0
- data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
- data/example/android/android_app/android_app_calculator/features/actual_images/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/calculator.feature +0 -36
- data/example/android/android_app/android_app_calculator/features/expected_images/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/image_difference/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/my_first.feature +0 -13
- data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +0 -5
- data/example/android/android_app/android_app_calculator/features/support/env.rb +0 -51
- data/example/android/android_app/android_app_calculator/features/support/hooks.rb +0 -38
- data/example/android/android_web/android_web_gmail_login.zip +0 -0
- data/example/android/android_web/android_web_gmail_login/features/actual_images/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/expected_images/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +0 -12
- data/example/android/android_web/android_web_gmail_login/features/image_difference/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/my_first.feature +0 -1
- data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
- data/example/android/android_web/android_web_gmail_login/features/support/env.rb +0 -51
- data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +0 -38
- data/example/desktop web/desktop_web_gmail_login.zip +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/actual_images/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/expected_images/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +0 -10
- data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +0 -22
- data/example/desktop web/desktop_web_gmail_login/features/image_difference/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +0 -1
- data/example/desktop web/desktop_web_gmail_login/features/result.html b/data/example/desktop → web/desktop_web_gmail_login/features/result.html +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
- data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +0 -51
- data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +0 -38
- data/example/desktop web/desktop_web_gmail_login/result.html +0 -478
@@ -1,242 +1,242 @@
|
|
1
|
-
require_relative 'required_files'
|
2
|
-
|
3
|
-
def swipe_using_elements(access_type1, access_name1, access_type2, access_name2)
|
4
|
-
|
5
|
-
# to get start x,y co-ordinates
|
6
|
-
ele_from = WAIT.until { $driver.find_element(:"#{access_type1}" => "#{access_name1}") }.location
|
7
|
-
start_x = ele_from.x
|
8
|
-
start_y = ele_from.y
|
9
|
-
|
10
|
-
# to get end x,y co-ordinates
|
11
|
-
ele_to = WAIT.until { $driver.find_element(:"#{access_type2}" => "#{access_name2}") }.location
|
12
|
-
end_x = ele_to.x
|
13
|
-
end_y = ele_to.y
|
14
|
-
|
15
|
-
swipe(start_x, start_y, end_x, end_y)
|
16
|
-
end
|
17
|
-
|
18
|
-
def swipe(start_x, start_y, end_x, end_y)
|
19
|
-
action = Appium::TouchAction.new.press(x: "#{start_x}", y: "#{start_y}").wait(1000).move_to(x: "#{end_x}", y: "#{end_y}").release()
|
20
|
-
action.perform
|
21
|
-
end
|
22
|
-
|
23
|
-
def swipe_direction(direction)
|
24
|
-
size = $driver.manage.window.size
|
25
|
-
height = size.height.to_i - 10
|
26
|
-
width = size.width.to_i - 10
|
27
|
-
|
28
|
-
if direction == 'right'
|
29
|
-
start_x = (width/100) * 15 # 83
|
30
|
-
start_y = height/2 # 695
|
31
|
-
end_x = (width/100) * 90 # 900
|
32
|
-
end_y = height/2 # 630
|
33
|
-
elsif direction == 'left'
|
34
|
-
start_x = (width/100) * 90
|
35
|
-
start_y = height/2
|
36
|
-
end_x = (width/100) * 15
|
37
|
-
end_y = height/2
|
38
|
-
elsif direction == 'up'
|
39
|
-
start_x = width/2
|
40
|
-
start_y = (height/100) * 90
|
41
|
-
end_x = width/2
|
42
|
-
end_y = (height/100) * 15
|
43
|
-
elsif direction == 'down'
|
44
|
-
start_x = width/2
|
45
|
-
start_y = (height/100) * 15
|
46
|
-
end_x = width/2
|
47
|
-
end_y = (height/100) * 90
|
48
|
-
else
|
49
|
-
raise "invalid direction"
|
50
|
-
end
|
51
|
-
|
52
|
-
swipe(start_x, start_y, end_x, end_y)
|
53
|
-
end
|
54
|
-
|
55
|
-
def swipe_element_with_direction(access_type, access_name, direction)
|
56
|
-
ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.location
|
57
|
-
x_start = ele_from.x
|
58
|
-
y_start = ele_from.y
|
59
|
-
|
60
|
-
ele_size = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }
|
61
|
-
ele_height = ele_size.size.height.to_i
|
62
|
-
ele_width = ele_size.size.width.to_i
|
63
|
-
#puts ele_size.width
|
64
|
-
|
65
|
-
x_end = x_start + ele_width
|
66
|
-
y_end = y_start + ele_height
|
67
|
-
|
68
|
-
puts "[#{x_start},#{y_start}],[#{x_end},#{y_end}]"
|
69
|
-
|
70
|
-
puts "ele_height : #{ele_height}" # 1776
|
71
|
-
puts "ele_width :#{ele_width}" #
|
72
|
-
|
73
|
-
size = $driver.manage.window.size
|
74
|
-
height = size.height.to_i - 5
|
75
|
-
puts "height : #{height}" # 1776
|
76
|
-
width = size.width.to_i - 5
|
77
|
-
puts "width :#{width}" #
|
78
|
-
|
79
|
-
if direction == 'right'
|
80
|
-
start_x = x_start + (ele_width*0.25)
|
81
|
-
start_y = (y_start) + (ele_height/2)
|
82
|
-
end_x = width # 900
|
83
|
-
end_y = (y_start) + (ele_height/2)
|
84
|
-
elsif direction == 'left'
|
85
|
-
start_x = x_end - 5
|
86
|
-
start_y = (y_end) - (ele_height/2)
|
87
|
-
end_x = 10
|
88
|
-
end_y = (y_end) - (ele_height/2)
|
89
|
-
elsif direction == 'up'
|
90
|
-
if ele_height > height
|
91
|
-
ele_height = height
|
92
|
-
end
|
93
|
-
|
94
|
-
if y_end > height
|
95
|
-
y_end = y_start + ele_height
|
96
|
-
end
|
97
|
-
|
98
|
-
puts "ele_height: #{ele_height}"
|
99
|
-
puts "ele_height*).75: #{ele_height*0.75}"
|
100
|
-
puts y_end
|
101
|
-
start_x = x_end - (ele_width/2)
|
102
|
-
|
103
|
-
start_y = (y_end) - (ele_height*0.75)
|
104
|
-
|
105
|
-
if start_y < 0
|
106
|
-
y_start = 0
|
107
|
-
y_end = y_start + ele_height
|
108
|
-
start_y = (y_end) - (ele_height*0.75)
|
109
|
-
# puts y_end
|
110
|
-
# puts "y_start: #{y_start}"
|
111
|
-
# puts "ele_height: #{ele_height}"
|
112
|
-
# puts "ele_height*0.75: #{ele_height*0.75}"
|
113
|
-
end
|
114
|
-
|
115
|
-
end_x = (x_end/2)
|
116
|
-
end_y = 10
|
117
|
-
elsif direction == 'down'
|
118
|
-
start_x = x_start + (ele_width/2)
|
119
|
-
if ele_height > height
|
120
|
-
ele_height = height
|
121
|
-
end
|
122
|
-
start_y = (y_start) + (ele_height*0.25)
|
123
|
-
if start_y < 0
|
124
|
-
y_start = 0
|
125
|
-
if ele_height > height
|
126
|
-
ele_height = height
|
127
|
-
end
|
128
|
-
start_y = (y_start) + (ele_height*0.25)
|
129
|
-
# puts y_end
|
130
|
-
# puts "y_start: #{y_start}"
|
131
|
-
puts "ele_height: #{ele_height}"
|
132
|
-
puts "ele_height*0.25: #{ele_height*0.25}"
|
133
|
-
end
|
134
|
-
end_x = x_start + (ele_width/2)
|
135
|
-
if ele_height > height
|
136
|
-
ele_height = height
|
137
|
-
end
|
138
|
-
end_y = ele_height
|
139
|
-
else
|
140
|
-
raise "invalid direction"
|
141
|
-
end
|
142
|
-
|
143
|
-
puts "start_x: #{start_x}, start_y: #{start_y}"
|
144
|
-
puts "end_x: #{end_x}, end_y: #{end_y}"
|
145
|
-
|
146
|
-
swipe(start_x, start_y, end_x, end_y)
|
147
|
-
end
|
148
|
-
|
149
|
-
def swipe_coordinates_with_direction(start_x, start_y, direction)
|
150
|
-
|
151
|
-
# ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.size
|
152
|
-
# height = size.height.to_i - 5
|
153
|
-
# puts "height : #{height}" # 1776
|
154
|
-
# width = size.width.to_i - 5
|
155
|
-
# puts "width :#{width}" #
|
156
|
-
|
157
|
-
size = $driver.manage.window.size
|
158
|
-
height = size.height.to_i - 5
|
159
|
-
puts "height : #{height}"
|
160
|
-
width = size.width.to_i - 5
|
161
|
-
puts "width :#{width}"
|
162
|
-
|
163
|
-
if direction == 'right'
|
164
|
-
start_x = start_x
|
165
|
-
start_y = start_y
|
166
|
-
end_x = width
|
167
|
-
end_y = start_y
|
168
|
-
elsif direction == 'left'
|
169
|
-
start_x = start_x
|
170
|
-
start_y = start_y
|
171
|
-
end_x = 10
|
172
|
-
end_y = start_y
|
173
|
-
elsif direction == 'up'
|
174
|
-
start_x = start_x
|
175
|
-
start_y = start_y
|
176
|
-
end_x = start_x
|
177
|
-
end_y = 10
|
178
|
-
elsif direction == 'down'
|
179
|
-
start_x = start_x
|
180
|
-
start_y = start_y
|
181
|
-
end_x = start_x
|
182
|
-
end_y = height
|
183
|
-
else
|
184
|
-
raise "invalid direction"
|
185
|
-
end
|
186
|
-
|
187
|
-
swipe(start_x, start_y, end_x, end_y)
|
188
|
-
end
|
189
|
-
|
190
|
-
|
191
|
-
def long_press_on_element_default_duration(access_type, access_name)
|
192
|
-
begin
|
193
|
-
ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.location
|
194
|
-
x = ele_from.x
|
195
|
-
y = ele_from.y
|
196
|
-
|
197
|
-
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
|
198
|
-
action.perform
|
199
|
-
rescue Exception => e
|
200
|
-
if e.to_s == 'The swipe did not complete successfully'
|
201
|
-
print ""
|
202
|
-
else
|
203
|
-
raise e
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def long_press_on_element_with_duration(access_type, access_name, duration)
|
209
|
-
begin
|
210
|
-
ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.location
|
211
|
-
x = ele_from.x
|
212
|
-
y = ele_from.y
|
213
|
-
|
214
|
-
duration = duration.to_i
|
215
|
-
duration = duration * 1000
|
216
|
-
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
|
217
|
-
action.perform
|
218
|
-
rescue Exception => e
|
219
|
-
if e.to_s == 'The swipe did not complete successfully'
|
220
|
-
print ""
|
221
|
-
else
|
222
|
-
raise e
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def long_press_on_coordinates(x, y)
|
228
|
-
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
|
229
|
-
action.perform
|
230
|
-
end
|
231
|
-
|
232
|
-
def long_press_on_coordinates_with_duration(x, y, duration)
|
233
|
-
duration = duration.to_i
|
234
|
-
duration = duration * 1000
|
235
|
-
puts duration
|
236
|
-
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
|
237
|
-
action.perform
|
238
|
-
end
|
239
|
-
|
240
|
-
def close_app
|
241
|
-
$driver.close_app
|
1
|
+
require_relative 'required_files'
|
2
|
+
|
3
|
+
def swipe_using_elements(access_type1, access_name1, access_type2, access_name2)
|
4
|
+
|
5
|
+
# to get start x,y co-ordinates
|
6
|
+
ele_from = WAIT.until { $driver.find_element(:"#{access_type1}" => "#{access_name1}") }.location
|
7
|
+
start_x = ele_from.x
|
8
|
+
start_y = ele_from.y
|
9
|
+
|
10
|
+
# to get end x,y co-ordinates
|
11
|
+
ele_to = WAIT.until { $driver.find_element(:"#{access_type2}" => "#{access_name2}") }.location
|
12
|
+
end_x = ele_to.x
|
13
|
+
end_y = ele_to.y
|
14
|
+
|
15
|
+
swipe(start_x, start_y, end_x, end_y)
|
16
|
+
end
|
17
|
+
|
18
|
+
def swipe(start_x, start_y, end_x, end_y)
|
19
|
+
action = Appium::TouchAction.new.press(x: "#{start_x}", y: "#{start_y}").wait(1000).move_to(x: "#{end_x}", y: "#{end_y}").release()
|
20
|
+
action.perform
|
21
|
+
end
|
22
|
+
|
23
|
+
def swipe_direction(direction)
|
24
|
+
size = $driver.manage.window.size
|
25
|
+
height = size.height.to_i - 10
|
26
|
+
width = size.width.to_i - 10
|
27
|
+
|
28
|
+
if direction == 'right'
|
29
|
+
start_x = (width/100) * 15 # 83
|
30
|
+
start_y = height/2 # 695
|
31
|
+
end_x = (width/100) * 90 # 900
|
32
|
+
end_y = height/2 # 630
|
33
|
+
elsif direction == 'left'
|
34
|
+
start_x = (width/100) * 90
|
35
|
+
start_y = height/2
|
36
|
+
end_x = (width/100) * 15
|
37
|
+
end_y = height/2
|
38
|
+
elsif direction == 'up'
|
39
|
+
start_x = width/2
|
40
|
+
start_y = (height/100) * 90
|
41
|
+
end_x = width/2
|
42
|
+
end_y = (height/100) * 15
|
43
|
+
elsif direction == 'down'
|
44
|
+
start_x = width/2
|
45
|
+
start_y = (height/100) * 15
|
46
|
+
end_x = width/2
|
47
|
+
end_y = (height/100) * 90
|
48
|
+
else
|
49
|
+
raise "invalid direction"
|
50
|
+
end
|
51
|
+
|
52
|
+
swipe(start_x, start_y, end_x, end_y)
|
53
|
+
end
|
54
|
+
|
55
|
+
def swipe_element_with_direction(access_type, access_name, direction)
|
56
|
+
ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.location
|
57
|
+
x_start = ele_from.x
|
58
|
+
y_start = ele_from.y
|
59
|
+
|
60
|
+
ele_size = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }
|
61
|
+
ele_height = ele_size.size.height.to_i
|
62
|
+
ele_width = ele_size.size.width.to_i
|
63
|
+
#puts ele_size.width
|
64
|
+
|
65
|
+
x_end = x_start + ele_width
|
66
|
+
y_end = y_start + ele_height
|
67
|
+
|
68
|
+
puts "[#{x_start},#{y_start}],[#{x_end},#{y_end}]"
|
69
|
+
|
70
|
+
puts "ele_height : #{ele_height}" # 1776
|
71
|
+
puts "ele_width :#{ele_width}" #
|
72
|
+
|
73
|
+
size = $driver.manage.window.size
|
74
|
+
height = size.height.to_i - 5
|
75
|
+
puts "height : #{height}" # 1776
|
76
|
+
width = size.width.to_i - 5
|
77
|
+
puts "width :#{width}" #
|
78
|
+
|
79
|
+
if direction == 'right'
|
80
|
+
start_x = x_start + (ele_width*0.25)
|
81
|
+
start_y = (y_start) + (ele_height/2)
|
82
|
+
end_x = width # 900
|
83
|
+
end_y = (y_start) + (ele_height/2)
|
84
|
+
elsif direction == 'left'
|
85
|
+
start_x = x_end - 5
|
86
|
+
start_y = (y_end) - (ele_height/2)
|
87
|
+
end_x = 10
|
88
|
+
end_y = (y_end) - (ele_height/2)
|
89
|
+
elsif direction == 'up'
|
90
|
+
if ele_height > height
|
91
|
+
ele_height = height
|
92
|
+
end
|
93
|
+
|
94
|
+
if y_end > height
|
95
|
+
y_end = y_start + ele_height
|
96
|
+
end
|
97
|
+
|
98
|
+
puts "ele_height: #{ele_height}"
|
99
|
+
puts "ele_height*).75: #{ele_height*0.75}"
|
100
|
+
puts y_end
|
101
|
+
start_x = x_end - (ele_width/2)
|
102
|
+
|
103
|
+
start_y = (y_end) - (ele_height*0.75)
|
104
|
+
|
105
|
+
if start_y < 0
|
106
|
+
y_start = 0
|
107
|
+
y_end = y_start + ele_height
|
108
|
+
start_y = (y_end) - (ele_height*0.75)
|
109
|
+
# puts y_end
|
110
|
+
# puts "y_start: #{y_start}"
|
111
|
+
# puts "ele_height: #{ele_height}"
|
112
|
+
# puts "ele_height*0.75: #{ele_height*0.75}"
|
113
|
+
end
|
114
|
+
|
115
|
+
end_x = (x_end/2)
|
116
|
+
end_y = 10
|
117
|
+
elsif direction == 'down'
|
118
|
+
start_x = x_start + (ele_width/2)
|
119
|
+
if ele_height > height
|
120
|
+
ele_height = height
|
121
|
+
end
|
122
|
+
start_y = (y_start) + (ele_height*0.25)
|
123
|
+
if start_y < 0
|
124
|
+
y_start = 0
|
125
|
+
if ele_height > height
|
126
|
+
ele_height = height
|
127
|
+
end
|
128
|
+
start_y = (y_start) + (ele_height*0.25)
|
129
|
+
# puts y_end
|
130
|
+
# puts "y_start: #{y_start}"
|
131
|
+
puts "ele_height: #{ele_height}"
|
132
|
+
puts "ele_height*0.25: #{ele_height*0.25}"
|
133
|
+
end
|
134
|
+
end_x = x_start + (ele_width/2)
|
135
|
+
if ele_height > height
|
136
|
+
ele_height = height
|
137
|
+
end
|
138
|
+
end_y = ele_height
|
139
|
+
else
|
140
|
+
raise "invalid direction"
|
141
|
+
end
|
142
|
+
|
143
|
+
puts "start_x: #{start_x}, start_y: #{start_y}"
|
144
|
+
puts "end_x: #{end_x}, end_y: #{end_y}"
|
145
|
+
|
146
|
+
swipe(start_x, start_y, end_x, end_y)
|
147
|
+
end
|
148
|
+
|
149
|
+
def swipe_coordinates_with_direction(start_x, start_y, direction)
|
150
|
+
|
151
|
+
# ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.size
|
152
|
+
# height = size.height.to_i - 5
|
153
|
+
# puts "height : #{height}" # 1776
|
154
|
+
# width = size.width.to_i - 5
|
155
|
+
# puts "width :#{width}" #
|
156
|
+
|
157
|
+
size = $driver.manage.window.size
|
158
|
+
height = size.height.to_i - 5
|
159
|
+
puts "height : #{height}"
|
160
|
+
width = size.width.to_i - 5
|
161
|
+
puts "width :#{width}"
|
162
|
+
|
163
|
+
if direction == 'right'
|
164
|
+
start_x = start_x
|
165
|
+
start_y = start_y
|
166
|
+
end_x = width
|
167
|
+
end_y = start_y
|
168
|
+
elsif direction == 'left'
|
169
|
+
start_x = start_x
|
170
|
+
start_y = start_y
|
171
|
+
end_x = 10
|
172
|
+
end_y = start_y
|
173
|
+
elsif direction == 'up'
|
174
|
+
start_x = start_x
|
175
|
+
start_y = start_y
|
176
|
+
end_x = start_x
|
177
|
+
end_y = 10
|
178
|
+
elsif direction == 'down'
|
179
|
+
start_x = start_x
|
180
|
+
start_y = start_y
|
181
|
+
end_x = start_x
|
182
|
+
end_y = height
|
183
|
+
else
|
184
|
+
raise "invalid direction"
|
185
|
+
end
|
186
|
+
|
187
|
+
swipe(start_x, start_y, end_x, end_y)
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
def long_press_on_element_default_duration(access_type, access_name)
|
192
|
+
begin
|
193
|
+
ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.location
|
194
|
+
x = ele_from.x
|
195
|
+
y = ele_from.y
|
196
|
+
|
197
|
+
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
|
198
|
+
action.perform
|
199
|
+
rescue Exception => e
|
200
|
+
if e.to_s == 'The swipe did not complete successfully'
|
201
|
+
print ""
|
202
|
+
else
|
203
|
+
raise e
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def long_press_on_element_with_duration(access_type, access_name, duration)
|
209
|
+
begin
|
210
|
+
ele_from = WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.location
|
211
|
+
x = ele_from.x
|
212
|
+
y = ele_from.y
|
213
|
+
|
214
|
+
duration = duration.to_i
|
215
|
+
duration = duration * 1000
|
216
|
+
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
|
217
|
+
action.perform
|
218
|
+
rescue Exception => e
|
219
|
+
if e.to_s == 'The swipe did not complete successfully'
|
220
|
+
print ""
|
221
|
+
else
|
222
|
+
raise e
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def long_press_on_coordinates(x, y)
|
228
|
+
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
|
229
|
+
action.perform
|
230
|
+
end
|
231
|
+
|
232
|
+
def long_press_on_coordinates_with_duration(x, y, duration)
|
233
|
+
duration = duration.to_i
|
234
|
+
duration = duration * 1000
|
235
|
+
puts duration
|
236
|
+
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
|
237
|
+
action.perform
|
238
|
+
end
|
239
|
+
|
240
|
+
def close_app
|
241
|
+
$driver.close_app
|
242
242
|
end
|