SurfCustomCalabash 0.1.3 → 0.2.0
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.
- checksums.yaml +5 -5
- data/SurfCustomCalabash.gemspec +1 -1
- data/lib/SurfCustomCalabash/CommonMethods.rb +293 -199
- data/lib/SurfCustomCalabash/DroidMethods.rb +103 -70
- data/lib/SurfCustomCalabash/IosMethods.rb +113 -68
- data/lib/SurfCustomCalabash/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2584314c724fb94ff419dd4513cf5ff7aff9cfa1aa096e57ee788b2f2f8eb14f
|
|
4
|
+
data.tar.gz: ba9ac40807f121a1dfab4e34b646528cc970c097cb1d32dcb08907231e88f1c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19a77b8a812760dfc779faf6580e315014ba9628919b6912744d63baab971bd6880edbd56a4c4d0466d57093b302bb2c49dcb42ecb7872e51607d55a6ec22495
|
|
7
|
+
data.tar.gz: b1e7895eade91dc479e2afffda0feabc4fb3cc639183e0f40e885827eac7a345f15e58f6a8ba1257fd7762019cc1d2c284516311bb8fb4578abb65b69a61cd78
|
data/SurfCustomCalabash.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ require "SurfCustomCalabash/version"
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "SurfCustomCalabash"
|
|
8
8
|
spec.version = SurfCustomCalabash::VERSION
|
|
9
|
-
spec.authors = ["Alexey Hripunov"]
|
|
9
|
+
spec.authors = ["Alexey Hripunov", "Igor Tolubaev"]
|
|
10
10
|
spec.email = ["hripunov@surfstudio.ru"]
|
|
11
11
|
|
|
12
12
|
spec.summary = "Custom methods for calabash ios and android"
|
|
@@ -1,271 +1,365 @@
|
|
|
1
1
|
require 'rspec/expectations'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
def enter_text_from_keyboard(text, timeout_duration: 5)
|
|
4
|
+
wait_for_keyboard(timeout: timeout_duration)
|
|
5
|
+
keyboard_enter_text(text)
|
|
6
|
+
end
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
# ----------------------------------------------Custom Taps-----------------------------------------------------------
|
|
9
|
+
# wait element and tap
|
|
10
|
+
def tap_on(element, timeout_duration: 15, sleep_duration: 0.5)
|
|
11
|
+
wait_element(element, timeout_duration: timeout_duration, sleep_duration: sleep_duration)
|
|
12
|
+
touch(element)
|
|
13
|
+
end
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
wait_for_elements_exist(element, :timeout=>15, :retry_frequency=>5)
|
|
15
|
-
sleep(0.5)
|
|
16
|
-
touch(element)
|
|
17
|
-
end
|
|
15
|
+
def tap_on_text(text, timeout_duration: 15, sleep_duration: 0.5)
|
|
16
|
+
tap_on("* {text CONTAINS'#{text}'}", timeout_duration: timeout_duration, sleep_duration: sleep_duration)
|
|
17
|
+
end
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
# if element exists - tap, if not - swipe until element exists and tap
|
|
20
|
+
def tap_or_swipe(element, timeout_duration: 30, sleep_duration: 0.5)
|
|
21
|
+
if element_does_not_exist(element)
|
|
22
|
+
light_swipe_until_exists('down', element, timeout_duration: timeout_duration)
|
|
21
23
|
end
|
|
24
|
+
tap_on(element, sleep_duration: sleep_duration)
|
|
25
|
+
end
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
else
|
|
29
|
-
until_element_exists(element,:action => lambda{light_swipe('down')}, :timeout => 30)
|
|
30
|
-
touch(element)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
27
|
+
# ----------------------------------------------------Custom Waits----------------------------------------------------
|
|
28
|
+
def wait_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3)
|
|
29
|
+
wait_for_element_exists(element, timeout: timeout_duration, retry_frequency: retry_frequency)
|
|
30
|
+
sleep(sleep_duration)
|
|
31
|
+
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
def wait_no_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3)
|
|
34
|
+
wait_for_element_does_not_exist(element, timeout: timeout_duration, retry_frequency: retry_frequency)
|
|
35
|
+
sleep(sleep_duration)
|
|
36
|
+
end
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
# wait trait-element on screen
|
|
39
|
+
def wait_for_screen(timeout_duration: 30, sleep_duration: 0, retry_frequency: 0.3)
|
|
40
|
+
wait_element(trait, sleep_duration: sleep_duration, timeout_duration: timeout_duration, retry_frequency: retry_frequency)
|
|
41
|
+
end
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
# ----------------------------------------------------Custom Swipe----------------------------------------------------
|
|
44
|
+
def strong_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
45
|
+
Timeout::timeout(timeout_duration) do
|
|
46
|
+
while element_exists(element_destination) do
|
|
47
|
+
strong_swipe(dir, sleep_duration: sleep_duration)
|
|
48
|
+
end
|
|
46
49
|
end
|
|
50
|
+
end
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
def normal_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
53
|
+
Timeout::timeout(timeout_duration) do
|
|
54
|
+
while element_exists(element_destination) do
|
|
55
|
+
normal_swipe(dir, sleep_duration: sleep_duration)
|
|
56
|
+
end
|
|
52
57
|
end
|
|
58
|
+
end
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
def light_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
61
|
+
Timeout::timeout(timeout_duration) do
|
|
62
|
+
while element_exists(element_destination) do
|
|
63
|
+
light_swipe(dir, sleep_duration: sleep_duration)
|
|
64
|
+
end
|
|
57
65
|
end
|
|
66
|
+
end
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
def strong_swipe_until_exists(dir, element_destination, sleep_duration: 0.5, timeout_duration: 30)
|
|
69
|
+
Timeout::timeout(timeout_duration) do
|
|
70
|
+
while element_does_not_exist(element_destination) do
|
|
71
|
+
strong_swipe(dir, sleep_duration: sleep_duration)
|
|
72
|
+
end
|
|
62
73
|
end
|
|
74
|
+
end
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
def normal_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
77
|
+
Timeout::timeout(timeout_duration) do
|
|
78
|
+
while element_does_not_exist(element_destination) do
|
|
79
|
+
normal_swipe(dir, sleep_duration: sleep_duration)
|
|
80
|
+
end
|
|
67
81
|
end
|
|
82
|
+
end
|
|
68
83
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
def light_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
85
|
+
Timeout::timeout(timeout_duration) do
|
|
86
|
+
while element_does_not_exist(element_destination) do
|
|
87
|
+
light_swipe(dir, sleep_duration: sleep_duration)
|
|
88
|
+
end
|
|
72
89
|
end
|
|
90
|
+
end
|
|
73
91
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
def strong_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30)
|
|
93
|
+
Timeout::timeout(timeout_duration) do
|
|
94
|
+
while element_does_not_exist(element_destination) do
|
|
95
|
+
strong_swipe_element(element, dir, sleep_duration: sleep_duration)
|
|
96
|
+
end
|
|
78
97
|
end
|
|
98
|
+
end
|
|
79
99
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
def normal_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
101
|
+
Timeout::timeout(timeout_duration) do
|
|
102
|
+
while element_does_not_exist(element_destination) do
|
|
103
|
+
normal_swipe_element(element, dir, sleep_duration: sleep_duration)
|
|
104
|
+
end
|
|
83
105
|
end
|
|
106
|
+
end
|
|
84
107
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
108
|
+
def light_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
109
|
+
Timeout::timeout(timeout_duration) do
|
|
110
|
+
while element_does_not_exist(element_destination) do
|
|
111
|
+
light_swipe_element(element, dir, sleep_duration: sleep_duration)
|
|
112
|
+
end
|
|
88
113
|
end
|
|
114
|
+
end
|
|
89
115
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
116
|
+
def strong_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30)
|
|
117
|
+
Timeout::timeout(timeout_duration) do
|
|
118
|
+
while element_exists(element_destination) do
|
|
119
|
+
strong_swipe_element(element, dir, sleep_duration: sleep_duration)
|
|
120
|
+
end
|
|
93
121
|
end
|
|
122
|
+
end
|
|
94
123
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
124
|
+
def normal_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
125
|
+
Timeout::timeout(timeout_duration) do
|
|
126
|
+
while element_exists(element_destination) do
|
|
127
|
+
normal_swipe_element(element, dir, sleep_duration: sleep_duration)
|
|
128
|
+
end
|
|
98
129
|
end
|
|
130
|
+
end
|
|
99
131
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
elsif dir == 'вниз'
|
|
105
|
-
until_element_exists("* {text CONTAINS'#{text}'}", :action => lambda{light_swipe('down'); sleep(1.5)}, :timeout => 60)
|
|
132
|
+
def light_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30)
|
|
133
|
+
Timeout::timeout(timeout_duration) do
|
|
134
|
+
while element_exists(element_destination) do
|
|
135
|
+
light_swipe_element(element, dir, sleep_duration: sleep_duration)
|
|
106
136
|
end
|
|
107
137
|
end
|
|
138
|
+
end
|
|
108
139
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
y_from = get_coordinate_y(element_from)
|
|
140
|
+
def swipe_to_text(dir, text, sleep_duration:0.2, timeout_duration: 30)
|
|
141
|
+
light_swipe_until_exists(dir, "* {text CONTAINS'#{text}'}", sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
142
|
+
end
|
|
113
143
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
144
|
+
# -------------------------------------------------Asserts------------------------------------------------------------
|
|
145
|
+
def assert_eql_with_rescue(element1, element2)
|
|
146
|
+
begin
|
|
147
|
+
expect(element1).to eq(element2)
|
|
148
|
+
true
|
|
149
|
+
rescue RSpec::Expectations::ExpectationNotMetError
|
|
150
|
+
false
|
|
117
151
|
end
|
|
152
|
+
end
|
|
118
153
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
expect(element1).to eq(element2)
|
|
123
|
-
true
|
|
124
|
-
rescue Exception => e
|
|
125
|
-
false
|
|
126
|
-
end
|
|
127
|
-
end
|
|
154
|
+
def assert_eql(element1, element2)
|
|
155
|
+
expect(element1).to eq(element2)
|
|
156
|
+
end
|
|
128
157
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
158
|
+
def assert_not_eql(element1, element2)
|
|
159
|
+
expect(element1).not_to eql(element2)
|
|
160
|
+
end
|
|
132
161
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
162
|
+
def assert_true(element)
|
|
163
|
+
expect(element).to be true
|
|
164
|
+
end
|
|
136
165
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
166
|
+
def assert_false(element)
|
|
167
|
+
expect(element).to be false
|
|
168
|
+
end
|
|
140
169
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
170
|
+
def assert_nil(element)
|
|
171
|
+
expect(element).to be_nil
|
|
172
|
+
end
|
|
144
173
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
174
|
+
# ------------------------------------------Generate String-----------------------------------------------------------
|
|
175
|
+
def get_random_num_string(length)
|
|
176
|
+
source = (0..9).to_a
|
|
177
|
+
key = ""
|
|
178
|
+
length.times{ key += source[rand(source.size)].to_s }
|
|
179
|
+
return key
|
|
180
|
+
end
|
|
148
181
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
end
|
|
182
|
+
def get_random_text_string(length)
|
|
183
|
+
source = ("a".."z").to_a
|
|
184
|
+
key = ""
|
|
185
|
+
length.times{ key += source[rand(source.size)].to_s }
|
|
186
|
+
return key
|
|
187
|
+
end
|
|
156
188
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
length.times{ key += source[rand(source.size)].to_s }
|
|
161
|
-
return key
|
|
162
|
-
end
|
|
189
|
+
def get_random_email
|
|
190
|
+
return get_random_text_string(7) + "@" + get_random_text_string(2) + ".test"
|
|
191
|
+
end
|
|
163
192
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
193
|
+
# get first digital from string
|
|
194
|
+
def extract_num_from_str(text)
|
|
195
|
+
text.gsub!(/[[:space:]]/, '')
|
|
196
|
+
num = text.scan(/\d+/).first.nil? ? "0" : text.scan(/\d+/).first
|
|
197
|
+
p num
|
|
198
|
+
end
|
|
167
199
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
200
|
+
# get last digital from string
|
|
201
|
+
def extract_last_num_from_str(text)
|
|
202
|
+
text.gsub!(/[[:space:]]/, '')
|
|
203
|
+
num = text.scan(/\d+/).first.nil? ? "0" : text.scan(/\d+/).last
|
|
204
|
+
p num
|
|
205
|
+
end
|
|
174
206
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
end
|
|
207
|
+
# get text from first element
|
|
208
|
+
def remember(element, sleep_duration: 1, timeout_duration: 5)
|
|
209
|
+
wait_element(element, sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
210
|
+
name = query(element)
|
|
211
|
+
save_name = name.first['text']
|
|
212
|
+
puts(save_name)
|
|
213
|
+
return save_name
|
|
214
|
+
end
|
|
184
215
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
end
|
|
216
|
+
# get text from last element
|
|
217
|
+
def remember_last_text(element, sleep_duration: 1, timeout_duration: 5)
|
|
218
|
+
wait_element(element, sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
219
|
+
name = query(element)
|
|
220
|
+
save_name = name.last['text']
|
|
221
|
+
puts(save_name)
|
|
222
|
+
return save_name
|
|
223
|
+
end
|
|
194
224
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
# wait text
|
|
226
|
+
def check_text(text, sleep_duration: 0, timeout_duration: 5)
|
|
227
|
+
wait_element("* {text CONTAINS'#{text}'}", sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
228
|
+
end
|
|
199
229
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
230
|
+
def no_check_text(text, timeout_duration: 5)
|
|
231
|
+
warn "Deprecated with 0.1.9 version SurfCustomCalabash, use check_no_text intead"
|
|
232
|
+
check_no_text(text, timeout_duration: timeout_duration)
|
|
233
|
+
end
|
|
203
234
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
coordinate = el[0]['rect']['center_x']
|
|
208
|
-
# puts(coordinate)
|
|
209
|
-
return coordinate.to_i
|
|
210
|
-
end
|
|
235
|
+
def check_no_text(text, sleep_duration: 0, timeout_duration: 5)
|
|
236
|
+
wait_no_element("* {text CONTAINS'#{text}'}", sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
237
|
+
end
|
|
211
238
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
239
|
+
# get element's coordinates
|
|
240
|
+
def get_coordinate_x(element)
|
|
241
|
+
el = query(element)
|
|
242
|
+
coordinate = el[0]['rect']['center_x']
|
|
243
|
+
return coordinate.to_i
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def get_coordinate_y(element)
|
|
247
|
+
el = query(element)
|
|
248
|
+
coordinate = el[0]['rect']['center_y']
|
|
249
|
+
return coordinate.to_i
|
|
250
|
+
end
|
|
218
251
|
|
|
252
|
+
# Drag element from one place to place of other element
|
|
253
|
+
def drag_element(element_from , element_to)
|
|
254
|
+
x_from = get_coordinate_x(element_from)
|
|
255
|
+
y_from = get_coordinate_y(element_from)
|
|
219
256
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
257
|
+
x_to = get_coordinate_x(element_to)
|
|
258
|
+
y_to = get_coordinate_y(element_to)
|
|
259
|
+
drag_coordinates(x_from, y_from, x_to, y_to, 10, 0.5, 0.5)
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# if elements cross - return true, if not - false
|
|
263
|
+
def cross_coordinate(element_front, element_behind, delta: 100)
|
|
264
|
+
cross = false
|
|
223
265
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
delta = 100
|
|
266
|
+
if element_exists(element_front) && element_exists(element_behind)
|
|
267
|
+
coordinate_front = get_coordinate_y(element_front)
|
|
268
|
+
coordinate_behind = get_coordinate_y(element_behind)
|
|
228
269
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
end
|
|
270
|
+
if coordinate_front < coordinate_behind + delta
|
|
271
|
+
cross = true
|
|
272
|
+
else
|
|
273
|
+
cross = false
|
|
234
274
|
end
|
|
235
|
-
# puts(cross)
|
|
236
|
-
return cross
|
|
237
275
|
end
|
|
276
|
+
# puts(cross)
|
|
277
|
+
return cross
|
|
278
|
+
end
|
|
238
279
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
280
|
+
# swipe down if two element cross
|
|
281
|
+
def swipe_if_cross(element_front, element_behind, timeout_duration: 30, sleep_duration: 1)
|
|
282
|
+
Timeout::timeout(timeout_duration) do
|
|
283
|
+
while cross_coordinate(element_front, element_behind) do
|
|
284
|
+
light_swipe("down", sleep_duration: sleep_duration)
|
|
243
285
|
end
|
|
244
|
-
sleep(1)
|
|
245
286
|
end
|
|
287
|
+
end
|
|
246
288
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
289
|
+
# --------------------------------------------------Localization------------------------------------------------------
|
|
290
|
+
# get locale apps - Ru or Eng
|
|
291
|
+
# parameter - element with text
|
|
292
|
+
def get_app_location(element, sleep_duration: 1)
|
|
293
|
+
sleep(sleep_duration)
|
|
294
|
+
if element_exists(element)
|
|
295
|
+
text_element = remember(element)
|
|
296
|
+
if check_cyrillic(text_element)
|
|
297
|
+
locale = 'RUS'
|
|
255
298
|
else
|
|
256
|
-
|
|
299
|
+
locale = 'ENG'
|
|
257
300
|
end
|
|
301
|
+
else
|
|
302
|
+
p "Fail localization"
|
|
303
|
+
locale = ''
|
|
258
304
|
end
|
|
305
|
+
p locale
|
|
306
|
+
return locale
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# check cyrillic symbols in string
|
|
310
|
+
def check_cyrillic(str)
|
|
311
|
+
regexp = /\p{Cyrillic}+.*?\.?/
|
|
312
|
+
if str.match(regexp).nil?
|
|
313
|
+
return false
|
|
314
|
+
else
|
|
315
|
+
return true
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# if apps support two localization, this method check exists text in different locations
|
|
320
|
+
def text_with_locale(text_locale1, text_locale2, sleep_duration: 1)
|
|
321
|
+
sleep(sleep_duration)
|
|
322
|
+
|
|
323
|
+
# $locale is global variables
|
|
324
|
+
# $locale setup in first app launch
|
|
325
|
+
if !$locale.nil?
|
|
326
|
+
if check_cyrillic(text_locale1)
|
|
327
|
+
rus_locale = "* {text CONTAINS '#{text_locale1}'}"
|
|
328
|
+
eng_locale = "* {text CONTAINS '#{text_locale2}'}"
|
|
329
|
+
elsif check_cyrillic(text_locale2)
|
|
330
|
+
rus_locale = "* {text CONTAINS '#{text_locale2}'}"
|
|
331
|
+
eng_locale = "* {text CONTAINS '#{text_locale1}'}"
|
|
332
|
+
end
|
|
259
333
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
|
|
334
|
+
if $locale == "RUS"
|
|
335
|
+
return rus_locale
|
|
336
|
+
elsif $locale == "ENG"
|
|
337
|
+
return eng_locale
|
|
338
|
+
end
|
|
339
|
+
else
|
|
340
|
+
# if $locale is not Rus or Eng
|
|
341
|
+
# wait element on screen with text_locale1 or text_locale2
|
|
342
|
+
locale_el1 = "* {text CONTAINS '#{text_locale1}'}"
|
|
343
|
+
locale_el2 = "* {text CONTAINS '#{text_locale2}'}"
|
|
344
|
+
|
|
345
|
+
if element_exists(locale_el1)
|
|
346
|
+
return locale_el1
|
|
347
|
+
elsif element_exists(locale_el2)
|
|
348
|
+
return locale_el2
|
|
266
349
|
else
|
|
267
|
-
return
|
|
350
|
+
return ("No such query!")
|
|
268
351
|
end
|
|
269
352
|
end
|
|
353
|
+
end
|
|
270
354
|
|
|
355
|
+
# if apps support two localization, this method check exists label in different locations
|
|
356
|
+
def label_with_locale(mark1, mark2)
|
|
357
|
+
if element_exists("* marked:'#{mark1}'")
|
|
358
|
+
return "* marked:'#{mark1}'"
|
|
359
|
+
elsif element_exists("* marked:'#{mark2}'")
|
|
360
|
+
return "* marked:'#{mark2}'"
|
|
361
|
+
else
|
|
362
|
+
return false
|
|
363
|
+
end
|
|
271
364
|
end
|
|
365
|
+
|
|
@@ -1,90 +1,123 @@
|
|
|
1
1
|
require 'calabash-android'
|
|
2
2
|
require 'SurfCustomCalabash/CommonMethods'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def close_keyboard
|
|
9
|
-
if keyboard_visible?
|
|
10
|
-
hide_soft_keyboard
|
|
11
|
-
end
|
|
4
|
+
def close_keyboard
|
|
5
|
+
if keyboard_visible?
|
|
6
|
+
hide_soft_keyboard
|
|
12
7
|
end
|
|
8
|
+
end
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
perform_action('drag', 50, 50, 15, 75, 4)
|
|
18
|
-
elsif dr == "down"
|
|
19
|
-
perform_action('drag', 50, 50, 60, 5, 1)
|
|
20
|
-
elsif dr == "left"
|
|
21
|
-
perform_action('drag', 90, 0, 50, 50, 10)
|
|
22
|
-
elsif dr == "right"
|
|
23
|
-
perform_action('drag', 0, 90, 50, 50, 10)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
10
|
+
def submit_keyboard
|
|
11
|
+
press_user_action_button
|
|
12
|
+
end
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
#----------------------------------------------Custom Android Swipe---------------------------------------------------
|
|
15
|
+
def strong_swipe(dr, sleep_duration: 0)
|
|
16
|
+
if dr == "up"
|
|
17
|
+
perform_action('drag', 50, 50, 15, 75, 25)
|
|
18
|
+
elsif dr == "down"
|
|
19
|
+
perform_action('drag', 50, 50, 75, 15, 25)
|
|
20
|
+
elsif dr == "left"
|
|
21
|
+
perform_action('drag', 90, 0, 50, 50, 10)
|
|
22
|
+
elsif dr == "right"
|
|
23
|
+
perform_action('drag', 0, 90, 50, 50, 10)
|
|
24
|
+
else
|
|
25
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
33
26
|
end
|
|
27
|
+
sleep(sleep_duration)
|
|
28
|
+
end
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
def normal_swipe(dr, sleep_duration: 0)
|
|
31
|
+
if dr == "up"
|
|
32
|
+
perform_action('drag', 50, 50, 15, 45, 25)
|
|
33
|
+
elsif dr == "down"
|
|
34
|
+
perform_action('drag', 50, 50, 45, 15, 25)
|
|
35
|
+
elsif dr == "left"
|
|
36
|
+
perform_action('drag', 50, 0, 50, 50, 10)
|
|
37
|
+
elsif dr == "right"
|
|
38
|
+
perform_action('drag', 0, 50, 50, 50, 10)
|
|
39
|
+
else
|
|
40
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
41
41
|
end
|
|
42
|
+
sleep(sleep_duration)
|
|
43
|
+
end
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
def light_swipe(dr, sleep_duration: 0)
|
|
46
|
+
if dr == "up"
|
|
47
|
+
perform_action('drag', 50, 50, 15, 30, 25)
|
|
48
|
+
elsif dr == "down"
|
|
49
|
+
perform_action('drag', 50, 50, 30, 15, 25)
|
|
50
|
+
elsif dr == "left"
|
|
51
|
+
perform_action('drag', 25, 0, 50, 50, 10)
|
|
52
|
+
elsif dr == "right"
|
|
53
|
+
perform_action('drag', 0, 25, 50, 50, 10)
|
|
54
|
+
else
|
|
55
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
53
56
|
end
|
|
57
|
+
sleep(sleep_duration)
|
|
58
|
+
end
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
def strong_swipe_element(element, dir, sleep_duration: 0)
|
|
61
|
+
if dir == 'left'
|
|
62
|
+
flick(element, :left)
|
|
63
|
+
elsif dir == 'right'
|
|
64
|
+
flick(element, :right)
|
|
65
|
+
elsif dir == 'down'
|
|
66
|
+
flick(element, :up)
|
|
67
|
+
elsif dir == 'up'
|
|
68
|
+
flick(element, :down)
|
|
69
|
+
else
|
|
70
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
65
71
|
end
|
|
72
|
+
sleep(sleep_duration)
|
|
73
|
+
end
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
def normal_swipe_element(element, dir, sleep_duration: 0)
|
|
76
|
+
if dir == 'left'
|
|
77
|
+
pan(element, :left)
|
|
78
|
+
elsif dir == 'right'
|
|
79
|
+
pan(element, :right)
|
|
80
|
+
elsif dir == 'down'
|
|
81
|
+
pan(element, :up)
|
|
82
|
+
elsif dir == 'up'
|
|
83
|
+
pan(element, :down)
|
|
84
|
+
else
|
|
85
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
77
86
|
end
|
|
87
|
+
sleep(sleep_duration)
|
|
88
|
+
end
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
def light_swipe_element(element, dir, sleep_duration: 0)
|
|
91
|
+
if dir == 'left'
|
|
92
|
+
pan(element, :left)
|
|
93
|
+
elsif dir == 'right'
|
|
94
|
+
pan(element, :right)
|
|
95
|
+
elsif dir == 'down'
|
|
96
|
+
pan(element, :up)
|
|
97
|
+
elsif dir == 'up'
|
|
98
|
+
pan(element, :down)
|
|
99
|
+
else
|
|
100
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
83
101
|
end
|
|
102
|
+
sleep(sleep_duration)
|
|
103
|
+
end
|
|
84
104
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
# swipe trait-element from element_destination
|
|
106
|
+
def light_swipe_trait_until_exists(dir, element_destination, sleep_duration: 0, timeout_duration: 30)
|
|
107
|
+
light_swipe_element_until_exists(dir, trait, element_destination, sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# pull-to-refresh screen
|
|
111
|
+
def ptr
|
|
112
|
+
perform_action('drag', 50, 50, 15, 75, 4)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# strong swipe to up of the screen
|
|
116
|
+
def swipe_to_up
|
|
117
|
+
5.times {perform_action('drag', 50, 50, 15, 70, 1)}
|
|
118
|
+
end
|
|
89
119
|
|
|
120
|
+
# strong swipe to down of the screen
|
|
121
|
+
def swipe_to_down
|
|
122
|
+
5.times {perform_action('drag', 50, 50, 60, 10, 1)}
|
|
90
123
|
end
|
|
@@ -1,89 +1,134 @@
|
|
|
1
1
|
require 'calabash-cucumber/ibase'
|
|
2
2
|
require 'SurfCustomCalabash/CommonMethods'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def strong_swipe(dir)
|
|
9
|
-
if dir == 'left'
|
|
10
|
-
swipe :left, force: :strong
|
|
11
|
-
elsif dir == 'right'
|
|
12
|
-
swipe :right, force: :strong
|
|
13
|
-
elsif dir == 'up'
|
|
14
|
-
swipe :down, force: :strong
|
|
15
|
-
elsif dir == 'down'
|
|
16
|
-
swipe :up, force: :strong
|
|
17
|
-
end
|
|
4
|
+
# close keyboard with a swipe of the screen
|
|
5
|
+
def close_keyboard
|
|
6
|
+
if keyboard_visible?
|
|
7
|
+
pan_coordinates({x: 100, y: 150}, {x: 100, y: 250})
|
|
18
8
|
end
|
|
9
|
+
end
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
elsif dir == 'down'
|
|
28
|
-
swipe :up, force: :normal
|
|
11
|
+
# tap on Done on keyboard
|
|
12
|
+
def submit_keyboard
|
|
13
|
+
if keyboard_visible?
|
|
14
|
+
if element_exists("* marked:'Toolbar Done Button'")
|
|
15
|
+
touch("* marked:'Toolbar Done Button'")
|
|
16
|
+
else
|
|
17
|
+
tap_keyboard_action_key
|
|
29
18
|
end
|
|
30
19
|
end
|
|
20
|
+
end
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
#----------------------------------------------Custom Swipe iOS-------------------------------------------------------
|
|
23
|
+
def strong_swipe(dir, sleep_duration: 0)
|
|
24
|
+
if dir == 'left'
|
|
25
|
+
swipe :left, force: :strong
|
|
26
|
+
elsif dir == 'right'
|
|
27
|
+
swipe :right, force: :strong
|
|
28
|
+
elsif dir == 'up'
|
|
29
|
+
swipe :down, force: :strong
|
|
30
|
+
elsif dir == 'down'
|
|
31
|
+
swipe :up, force: :strong
|
|
32
|
+
else
|
|
33
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
42
34
|
end
|
|
35
|
+
sleep(sleep_duration)
|
|
36
|
+
end
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
def normal_swipe(dir, sleep_duration: 0)
|
|
39
|
+
if dir == 'left'
|
|
40
|
+
swipe :left, force: :normal
|
|
41
|
+
elsif dir == 'right'
|
|
42
|
+
swipe :right, force: :normal
|
|
43
|
+
elsif dir == 'up'
|
|
44
|
+
swipe :down, force: :normal
|
|
45
|
+
elsif dir == 'down'
|
|
46
|
+
swipe :up, force: :normal
|
|
47
|
+
else
|
|
48
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
54
49
|
end
|
|
50
|
+
sleep(sleep_duration)
|
|
51
|
+
end
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
def light_swipe(dir, sleep_duration: 0)
|
|
54
|
+
if dir == 'left'
|
|
55
|
+
swipe :left, force: :light
|
|
56
|
+
elsif dir == 'right'
|
|
57
|
+
swipe :right, force: :light
|
|
58
|
+
elsif dir == 'up'
|
|
59
|
+
swipe :down, force: :light
|
|
60
|
+
elsif dir == 'down'
|
|
61
|
+
swipe :up, force: :light
|
|
62
|
+
else
|
|
63
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
66
64
|
end
|
|
65
|
+
sleep(sleep_duration)
|
|
66
|
+
end
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
def strong_swipe_element(element, dir, sleep_duration: 0)
|
|
69
|
+
if dir == 'left'
|
|
70
|
+
swipe :left, :query => element, force: :strong
|
|
71
|
+
elsif dir == 'right'
|
|
72
|
+
swipe :right, :query => element, force: :strong
|
|
73
|
+
elsif dir == 'up'
|
|
74
|
+
swipe :down, :query => element, force: :strong
|
|
75
|
+
elsif dir == 'down'
|
|
76
|
+
swipe :up, :query => element, force: :strong
|
|
77
|
+
else
|
|
78
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
78
79
|
end
|
|
80
|
+
sleep(sleep_duration)
|
|
81
|
+
end
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
def normal_swipe_element(element, dir, sleep_duration: 0)
|
|
84
|
+
if dir == 'left'
|
|
85
|
+
swipe :left, :query => element, force: :normal
|
|
86
|
+
elsif dir == 'right'
|
|
87
|
+
swipe :right, :query => element, force: :normal
|
|
88
|
+
elsif dir == 'up'
|
|
89
|
+
swipe :down, :query => element, force: :normal
|
|
90
|
+
elsif dir == 'down'
|
|
91
|
+
swipe :up, :query => element, force: :normal
|
|
92
|
+
else
|
|
93
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
82
94
|
end
|
|
95
|
+
sleep(sleep_duration)
|
|
96
|
+
end
|
|
83
97
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
swipe
|
|
98
|
+
def light_swipe_element(element, dir, sleep_duration: 0)
|
|
99
|
+
if dir == 'left'
|
|
100
|
+
swipe :left, :query => element, force: :light
|
|
101
|
+
elsif dir == 'right'
|
|
102
|
+
swipe :right, :query => element, force: :light
|
|
103
|
+
elsif dir == 'up'
|
|
104
|
+
swipe :down, :query => element, force: :light
|
|
105
|
+
elsif dir == 'down'
|
|
106
|
+
swipe :up, :query => element, force: :light
|
|
107
|
+
else
|
|
108
|
+
p "Use direction 'up', 'down', 'left', 'right'"
|
|
87
109
|
end
|
|
110
|
+
sleep(sleep_duration)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def light_swipe_trait_until_exists(dir, element_destination, sleep_duration: 0, timeout_duration: 30)
|
|
114
|
+
normal_swipe_until_exists(dir, element_destination, sleep_duration: sleep_duration, timeout_duration: timeout_duration)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# pull-to-refresh screen
|
|
118
|
+
def ptr
|
|
119
|
+
pan_coordinates({x: 50, y: 100}, {x: 50, y: 600})
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# touch on status bar -> scroll to up of the screen
|
|
123
|
+
def swipe_to_up
|
|
124
|
+
touch(nil, :offset => {:x => 0, :y => 0})
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# strong swipe to down of the screen
|
|
128
|
+
def swipe_to_down
|
|
129
|
+
10.times {swipe :up, force: :strong}
|
|
130
|
+
end
|
|
88
131
|
|
|
132
|
+
def back_swipe
|
|
133
|
+
pan_coordinates({x:0, y:300}, {x:500, y:300})
|
|
89
134
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: SurfCustomCalabash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexey Hripunov
|
|
8
|
-
|
|
8
|
+
- Igor Tolubaev
|
|
9
|
+
autorequire:
|
|
9
10
|
bindir: exe
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: bundler
|
|
@@ -81,7 +82,7 @@ metadata:
|
|
|
81
82
|
homepage_uri: https://github.com/alexeyhripunov/SurfCustomCalabash
|
|
82
83
|
source_code_uri: https://github.com/alexeyhripunov/SurfCustomCalabash
|
|
83
84
|
changelog_uri: https://github.com/alexeyhripunov/SurfCustomCalabash
|
|
84
|
-
post_install_message:
|
|
85
|
+
post_install_message:
|
|
85
86
|
rdoc_options: []
|
|
86
87
|
require_paths:
|
|
87
88
|
- lib
|
|
@@ -96,9 +97,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
97
|
- !ruby/object:Gem::Version
|
|
97
98
|
version: '0'
|
|
98
99
|
requirements: []
|
|
99
|
-
rubyforge_project:
|
|
100
|
-
rubygems_version: 2.
|
|
101
|
-
signing_key:
|
|
100
|
+
rubyforge_project:
|
|
101
|
+
rubygems_version: 2.7.6
|
|
102
|
+
signing_key:
|
|
102
103
|
specification_version: 4
|
|
103
104
|
summary: Custom methods for calabash ios and android
|
|
104
105
|
test_files: []
|