Top Level Namespace
Defined Under Namespace
Modules: SurfCustomCalabash
Instance Method Summary collapse
- #assert_eql(element1, element2) ⇒ Object
-
#assert_eql_with_rescue(element1, element2) ⇒ Object
————————————————-Asserts————————————————————.
- #assert_false(element) ⇒ Object
- #assert_nil(element) ⇒ Object
- #assert_not_eql(element1, element2) ⇒ Object
- #assert_true(element) ⇒ Object
- #back_swipe ⇒ Object
-
#check_cyrillic(str) ⇒ Object
check cyrillic symbols in string.
- #check_no_text(text, sleep_duration: 0, timeout_duration: 5) ⇒ Object
-
#check_text(text, sleep_duration: 0, timeout_duration: 5) ⇒ Object
wait text.
-
#close_keyboard(x_start: 0, y_start: 0) ⇒ Object
close keyboard, parameters use ios only.
-
#cross_coordinate(element_front, element_behind, delta: 100) ⇒ Object
if elements cross - return true, if not - false.
-
#drag_element(element_from, element_to) ⇒ Object
Drag element from one place to place of other element.
- #enter_text_from_keyboard(text, timeout_duration: 5) ⇒ Object
-
#extract_last_num_from_str(text) ⇒ Object
get last digital from string.
-
#extract_num_from_str(text) ⇒ Object
get first digital from string.
-
#get_app_location(element, sleep_duration: 1) ⇒ Object
————————————————–Localization—————————————————— get locale apps - Ru or Eng parameter - element with text.
-
#get_coordinate_x(element) ⇒ Object
get element’s coordinates.
- #get_coordinate_y(element) ⇒ Object
- #get_random_email ⇒ Object
-
#get_random_num_string(length) ⇒ Object
——————————————Generate String———————————————————–.
- #get_random_text_string(length) ⇒ Object
-
#label_with_locale(mark1, mark2) ⇒ Object
if apps support two localization, this method check exists label in different locations.
- #light_swipe(dr, sleep_duration: 0) ⇒ Object
- #light_swipe_element(element, dir, sleep_duration: 0) ⇒ Object
- #light_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
- #light_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
-
#light_swipe_trait_until_exists(dir, element_destination, sleep_duration: 0, timeout_duration: 30) ⇒ Object
swipe trait-element from element_destination.
- #light_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
- #light_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
- #no_check_text(text, timeout_duration: 5) ⇒ Object
- #normal_swipe(dr, sleep_duration: 0) ⇒ Object
- #normal_swipe_element(element, dir, sleep_duration: 0) ⇒ Object
- #normal_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
- #normal_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
- #normal_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
- #normal_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
-
#ptr ⇒ Object
pull-to-refresh screen.
-
#remember(element, sleep_duration: 1, timeout_duration: 5) ⇒ Object
get text from first element.
-
#remember_last_text(element, sleep_duration: 1, timeout_duration: 5) ⇒ Object
get text from last element.
-
#strong_swipe(dr, sleep_duration: 0) ⇒ Object
———————————————-Custom Android Swipe—————————————————.
- #strong_swipe_element(element, dir, sleep_duration: 0) ⇒ Object
- #strong_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30) ⇒ Object
- #strong_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30) ⇒ Object
- #strong_swipe_until_exists(dir, element_destination, sleep_duration: 0.5, timeout_duration: 30) ⇒ Object
-
#strong_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
—————————————————-Custom Swipe—————————————————-.
-
#submit_keyboard ⇒ Object
tap on Done on keyboard.
-
#swipe_if_cross(element_front, element_behind, timeout_duration: 30, sleep_duration: 1) ⇒ Object
swipe down if two element cross.
-
#swipe_to_down ⇒ Object
strong swipe to down of the screen.
- #swipe_to_text(dir, text, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
-
#swipe_to_up ⇒ Object
strong swipe to up of the screen.
-
#tap_on(element, timeout_duration: 15, sleep_duration: 0.5) ⇒ Object
———————————————-Custom Taps———————————————————– wait element and tap.
- #tap_on_text(text, timeout_duration: 15, sleep_duration: 0.5) ⇒ Object
-
#tap_or_swipe(element, timeout_duration: 30, sleep_duration: 0.5) ⇒ Object
if element exists - tap, if not - swipe until element exists and tap.
-
#text_with_locale(text_locale1, text_locale2, sleep_duration: 1) ⇒ Object
if apps support two localization, this method check exists text in different locations.
-
#wait_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3) ⇒ Object
—————————————————-Custom Waits—————————————————-.
-
#wait_for_screen(timeout_duration: 30, sleep_duration: 0, retry_frequency: 0.3) ⇒ Object
wait trait-element on screen.
- #wait_no_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3) ⇒ Object
Instance Method Details
#assert_eql(element1, element2) ⇒ Object
154 155 156 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 154 def assert_eql(element1, element2) expect(element1).to eq(element2) end |
#assert_eql_with_rescue(element1, element2) ⇒ Object
————————————————-Asserts————————————————————
145 146 147 148 149 150 151 152 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 145 def assert_eql_with_rescue(element1, element2) begin expect(element1).to eq(element2) true rescue RSpec::Expectations::ExpectationNotMetError false end end |
#assert_false(element) ⇒ Object
166 167 168 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 166 def assert_false(element) expect(element).to be false end |
#assert_nil(element) ⇒ Object
170 171 172 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 170 def assert_nil(element) expect(element).to be_nil end |
#assert_not_eql(element1, element2) ⇒ Object
158 159 160 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 158 def assert_not_eql(element1, element2) expect(element1).not_to eql(element2) end |
#assert_true(element) ⇒ Object
162 163 164 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 162 def assert_true(element) expect(element).to be true end |
#back_swipe ⇒ Object
132 133 134 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 132 def back_swipe pan_coordinates({x:0, y:300}, {x:500, y:300}) end |
#check_cyrillic(str) ⇒ Object
check cyrillic symbols in string
310 311 312 313 314 315 316 317 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 310 def check_cyrillic(str) regexp = /\p{Cyrillic}+.*?\.?/ if str.match(regexp).nil? return false else return true end end |
#check_no_text(text, sleep_duration: 0, timeout_duration: 5) ⇒ Object
235 236 237 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 235 def check_no_text(text, sleep_duration: 0, timeout_duration: 5) wait_no_element("* {text CONTAINS'#{text}'}", sleep_duration: sleep_duration, timeout_duration: timeout_duration) end |
#check_text(text, sleep_duration: 0, timeout_duration: 5) ⇒ Object
wait text
226 227 228 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 226 def check_text(text, sleep_duration: 0, timeout_duration: 5) wait_element("* {text CONTAINS'#{text}'}", sleep_duration: sleep_duration, timeout_duration: timeout_duration) end |
#close_keyboard(x_start: 0, y_start: 0) ⇒ Object
close keyboard, parameters use ios only
5 6 7 8 9 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 5 def close_keyboard(x_start: 100, y_start: 150) if keyboard_visible? pan_coordinates({x: x_start, y: y_start}, {x: x_start, y: y_start+100}) end end |
#cross_coordinate(element_front, element_behind, delta: 100) ⇒ Object
if elements cross - return true, if not - false
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 263 def cross_coordinate(element_front, element_behind, delta: 100) cross = false if element_exists(element_front) && element_exists(element_behind) coordinate_front = get_coordinate_y(element_front) coordinate_behind = get_coordinate_y(element_behind) if coordinate_front < coordinate_behind + delta cross = true else cross = false end end # Kernel.puts(cross) return cross end |
#drag_element(element_from, element_to) ⇒ Object
Drag element from one place to place of other element
253 254 255 256 257 258 259 260 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 253 def drag_element(element_from , element_to) x_from = get_coordinate_x(element_from) y_from = get_coordinate_y(element_from) x_to = get_coordinate_x(element_to) y_to = get_coordinate_y(element_to) drag_coordinates(x_from, y_from, x_to, y_to, 10, 0.5, 0.5) end |
#enter_text_from_keyboard(text, timeout_duration: 5) ⇒ Object
3 4 5 6 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 3 def enter_text_from_keyboard(text, timeout_duration: 5) wait_for_keyboard(timeout: timeout_duration) keyboard_enter_text(text) end |
#extract_last_num_from_str(text) ⇒ Object
get last digital from string
201 202 203 204 205 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 201 def extract_last_num_from_str(text) text.gsub!(/[[:space:]]/, '') num = text.scan(/\d+/).first.nil? ? "0" : text.scan(/\d+/).last p num end |
#extract_num_from_str(text) ⇒ Object
get first digital from string
194 195 196 197 198 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 194 def extract_num_from_str(text) text.gsub!(/[[:space:]]/, '') num = text.scan(/\d+/).first.nil? ? "0" : text.scan(/\d+/).first p num end |
#get_app_location(element, sleep_duration: 1) ⇒ Object
————————————————–Localization—————————————————— get locale apps - Ru or Eng parameter - element with text
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 292 def get_app_location(element, sleep_duration: 1) sleep(sleep_duration) if element_exists(element) text_element = remember(element) if check_cyrillic(text_element) locale = 'RUS' else locale = 'ENG' end else p "Fail localization" locale = '' end p locale return locale end |
#get_coordinate_x(element) ⇒ Object
get element’s coordinates
240 241 242 243 244 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 240 def get_coordinate_x(element) el = query(element) coordinate = el[0]['rect']['center_x'] return coordinate.to_i end |
#get_coordinate_y(element) ⇒ Object
246 247 248 249 250 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 246 def get_coordinate_y(element) el = query(element) coordinate = el[0]['rect']['center_y'] return coordinate.to_i end |
#get_random_email ⇒ Object
189 190 191 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 189 def get_random_email return get_random_text_string(7) + "@" + get_random_text_string(2) + ".test" end |
#get_random_num_string(length) ⇒ Object
——————————————Generate String———————————————————–
175 176 177 178 179 180 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 175 def get_random_num_string(length) source = (0..9).to_a key = "" length.times{ key += source[rand(source.size)].to_s } return key end |
#get_random_text_string(length) ⇒ Object
182 183 184 185 186 187 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 182 def get_random_text_string(length) source = ("a".."z").to_a key = "" length.times{ key += source[rand(source.size)].to_s } return key end |
#label_with_locale(mark1, mark2) ⇒ Object
if apps support two localization, this method check exists label in different locations
356 357 358 359 360 361 362 363 364 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 356 def label_with_locale(mark1, mark2) if element_exists("* marked:'#{mark1}'") return "* marked:'#{mark1}'" elsif element_exists("* marked:'#{mark2}'") return "* marked:'#{mark2}'" else return false end end |
#light_swipe(dr, sleep_duration: 0) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 53 def light_swipe(dir, sleep_duration: 0) if dir == 'left' swipe :left, force: :light elsif dir == 'right' swipe :right, force: :light elsif dir == 'up' swipe :down, force: :light elsif dir == 'down' swipe :up, force: :light else p "Use direction 'up', 'down', 'left', 'right'" end sleep(sleep_duration) end |
#light_swipe_element(element, dir, sleep_duration: 0) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 98 def light_swipe_element(element, dir, sleep_duration: 0) if dir == 'left' swipe :left, :query => element, force: :light elsif dir == 'right' swipe :right, :query => element, force: :light elsif dir == 'up' swipe :down, :query => element, force: :light elsif dir == 'down' swipe :up, :query => element, force: :light else p "Use direction 'up', 'down', 'left', 'right'" end sleep(sleep_duration) end |
#light_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 108 def light_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_does_not_exist(element_destination) do light_swipe_element(element, dir, sleep_duration: sleep_duration) end end end |
#light_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 132 def light_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_exists(element_destination) do light_swipe_element(element, dir, sleep_duration: sleep_duration) end end end |
#light_swipe_trait_until_exists(dir, element_destination, sleep_duration: 0, timeout_duration: 30) ⇒ Object
swipe trait-element from element_destination
107 108 109 |
# File 'lib/SurfCustomCalabash/DroidMethods.rb', line 107 def light_swipe_trait_until_exists(dir, element_destination, sleep_duration: 0, timeout_duration: 30) normal_swipe_until_exists(dir, element_destination, sleep_duration: sleep_duration, timeout_duration: timeout_duration) end |
#light_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 84 def light_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_does_not_exist(element_destination) do light_swipe(dir, sleep_duration: sleep_duration) end end end |
#light_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 60 def light_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_exists(element_destination) do light_swipe(dir, sleep_duration: sleep_duration) end end end |
#no_check_text(text, timeout_duration: 5) ⇒ Object
230 231 232 233 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 230 def no_check_text(text, timeout_duration: 5) warn "Deprecated with 0.1.9 version SurfCustomCalabash, use check_no_text intead" check_no_text(text, timeout_duration: timeout_duration) end |
#normal_swipe(dr, sleep_duration: 0) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 38 def normal_swipe(dir, sleep_duration: 0) if dir == 'left' swipe :left, force: :normal elsif dir == 'right' swipe :right, force: :normal elsif dir == 'up' swipe :down, force: :normal elsif dir == 'down' swipe :up, force: :normal else p "Use direction 'up', 'down', 'left', 'right'" end sleep(sleep_duration) end |
#normal_swipe_element(element, dir, sleep_duration: 0) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 83 def normal_swipe_element(element, dir, sleep_duration: 0) if dir == 'left' swipe :left, :query => element, force: :normal elsif dir == 'right' swipe :right, :query => element, force: :normal elsif dir == 'up' swipe :down, :query => element, force: :normal elsif dir == 'down' swipe :up, :query => element, force: :normal else p "Use direction 'up', 'down', 'left', 'right'" end sleep(sleep_duration) end |
#normal_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 100 def normal_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_does_not_exist(element_destination) do normal_swipe_element(element, dir, sleep_duration: sleep_duration) end end end |
#normal_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 124 def normal_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_exists(element_destination) do normal_swipe_element(element, dir, sleep_duration: sleep_duration) end end end |
#normal_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 76 def normal_swipe_until_exists(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_does_not_exist(element_destination) do normal_swipe(dir, sleep_duration: sleep_duration) end end end |
#normal_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 52 def normal_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_exists(element_destination) do normal_swipe(dir, sleep_duration: sleep_duration) end end end |
#ptr ⇒ Object
pull-to-refresh screen
118 119 120 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 118 def ptr pan_coordinates({x: 50, y: 100}, {x: 50, y: 600}) end |
#remember(element, sleep_duration: 1, timeout_duration: 5) ⇒ Object
get text from first element
208 209 210 211 212 213 214 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 208 def remember(element, sleep_duration: 1, timeout_duration: 5) wait_element(element, sleep_duration: sleep_duration, timeout_duration: timeout_duration) name = query(element) save_name = name.first['text'] Kernel.puts(save_name) return save_name end |
#remember_last_text(element, sleep_duration: 1, timeout_duration: 5) ⇒ Object
get text from last element
217 218 219 220 221 222 223 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 217 def remember_last_text(element, sleep_duration: 1, timeout_duration: 5) wait_element(element, sleep_duration: sleep_duration, timeout_duration: timeout_duration) name = query(element) save_name = name.last['text'] Kernel.puts(save_name) return save_name end |
#strong_swipe(dr, sleep_duration: 0) ⇒ Object
———————————————-Custom Android Swipe—————————————————
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 23 def strong_swipe(dir, sleep_duration: 0) if dir == 'left' swipe :left, force: :strong elsif dir == 'right' swipe :right, force: :strong elsif dir == 'up' swipe :down, force: :strong elsif dir == 'down' swipe :up, force: :strong else p "Use direction 'up', 'down', 'left', 'right'" end sleep(sleep_duration) end |
#strong_swipe_element(element, dir, sleep_duration: 0) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 68 def strong_swipe_element(element, dir, sleep_duration: 0) if dir == 'left' swipe :left, :query => element, force: :strong elsif dir == 'right' swipe :right, :query => element, force: :strong elsif dir == 'up' swipe :down, :query => element, force: :strong elsif dir == 'down' swipe :up, :query => element, force: :strong else p "Use direction 'up', 'down', 'left', 'right'" end sleep(sleep_duration) end |
#strong_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 92 def strong_swipe_element_until_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_does_not_exist(element_destination) do strong_swipe_element(element, dir, sleep_duration: sleep_duration) end end end |
#strong_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 116 def strong_swipe_element_until_not_exists(dir, element, element_destination, sleep_duration: 0.5, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_exists(element_destination) do strong_swipe_element(element, dir, sleep_duration: sleep_duration) end end end |
#strong_swipe_until_exists(dir, element_destination, sleep_duration: 0.5, timeout_duration: 30) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 68 def strong_swipe_until_exists(dir, element_destination, sleep_duration: 0.5, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_does_not_exist(element_destination) do strong_swipe(dir, sleep_duration: sleep_duration) end end end |
#strong_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
—————————————————-Custom Swipe—————————————————-
44 45 46 47 48 49 50 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 44 def strong_swipe_until_not_exist(dir, element_destination, sleep_duration: 0.2, timeout_duration: 30) Timeout::timeout(timeout_duration) do while element_exists(element_destination) do strong_swipe(dir, sleep_duration: sleep_duration) end end end |
#submit_keyboard ⇒ Object
tap on Done on keyboard
12 13 14 15 16 17 18 19 20 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 12 def submit_keyboard if keyboard_visible? if element_exists("* marked:'Toolbar Done Button'") touch("* marked:'Toolbar Done Button'") else tap_keyboard_action_key end end end |
#swipe_if_cross(element_front, element_behind, timeout_duration: 30, sleep_duration: 1) ⇒ Object
swipe down if two element cross
281 282 283 284 285 286 287 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 281 def swipe_if_cross(element_front, element_behind, timeout_duration: 30, sleep_duration: 1) Timeout::timeout(timeout_duration) do while cross_coordinate(element_front, element_behind) do light_swipe("down", sleep_duration: sleep_duration) end end end |
#swipe_to_down ⇒ Object
strong swipe to down of the screen
128 129 130 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 128 def swipe_to_down 10.times {swipe :up, force: :strong} end |
#swipe_to_text(dir, text, sleep_duration: 0.2, timeout_duration: 30) ⇒ Object
140 141 142 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 140 def swipe_to_text(dir, text, sleep_duration:0.2, timeout_duration: 30) light_swipe_until_exists(dir, "* {text CONTAINS'#{text}'}", sleep_duration: sleep_duration, timeout_duration: timeout_duration) end |
#swipe_to_up ⇒ Object
strong swipe to up of the screen
123 124 125 |
# File 'lib/SurfCustomCalabash/IosMethods.rb', line 123 def swipe_to_up touch(nil, :offset => {:x => 0, :y => 0}) end |
#tap_on(element, timeout_duration: 15, sleep_duration: 0.5) ⇒ Object
———————————————-Custom Taps———————————————————– wait element and tap
10 11 12 13 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 10 def tap_on(element, timeout_duration: 15, sleep_duration: 0.5) wait_element(element, timeout_duration: timeout_duration, sleep_duration: sleep_duration) touch(element) end |
#tap_on_text(text, timeout_duration: 15, sleep_duration: 0.5) ⇒ Object
15 16 17 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 15 def tap_on_text(text, timeout_duration: 15, sleep_duration: 0.5) tap_on("* {text CONTAINS'#{text}'}", timeout_duration: timeout_duration, sleep_duration: sleep_duration) end |
#tap_or_swipe(element, timeout_duration: 30, sleep_duration: 0.5) ⇒ Object
if element exists - tap, if not - swipe until element exists and tap
20 21 22 23 24 25 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 20 def tap_or_swipe(element, timeout_duration: 30, sleep_duration: 0.5) if element_does_not_exist(element) light_swipe_until_exists('down', element, timeout_duration: timeout_duration) end tap_on(element, sleep_duration: sleep_duration) end |
#text_with_locale(text_locale1, text_locale2, sleep_duration: 1) ⇒ Object
if apps support two localization, this method check exists text in different locations
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 320 def text_with_locale(text_locale1, text_locale2, sleep_duration: 1) sleep(sleep_duration) # $locale is global variables # $locale setup in first app launch if !$locale.nil? if check_cyrillic(text_locale1) rus_locale = "* {text CONTAINS '#{text_locale1}'}" eng_locale = "* {text CONTAINS '#{text_locale2}'}" elsif check_cyrillic(text_locale2) rus_locale = "* {text CONTAINS '#{text_locale2}'}" eng_locale = "* {text CONTAINS '#{text_locale1}'}" end if $locale == "RUS" return rus_locale elsif $locale == "ENG" return eng_locale end else # if $locale is not Rus or Eng # wait element on screen with text_locale1 or text_locale2 locale_el1 = "* {text CONTAINS '#{text_locale1}'}" locale_el2 = "* {text CONTAINS '#{text_locale2}'}" if element_exists(locale_el1) return locale_el1 elsif element_exists(locale_el2) return locale_el2 else return ("No such query!") end end end |
#wait_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3) ⇒ Object
—————————————————-Custom Waits—————————————————-
28 29 30 31 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 28 def wait_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3) wait_for_element_exists(element, timeout: timeout_duration, retry_frequency: retry_frequency) sleep(sleep_duration) end |
#wait_for_screen(timeout_duration: 30, sleep_duration: 0, retry_frequency: 0.3) ⇒ Object
wait trait-element on screen
39 40 41 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 39 def wait_for_screen(timeout_duration: 30, sleep_duration: 0, retry_frequency: 0.3) wait_element(trait, sleep_duration: sleep_duration, timeout_duration: timeout_duration, retry_frequency: retry_frequency) end |
#wait_no_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3) ⇒ Object
33 34 35 36 |
# File 'lib/SurfCustomCalabash/CommonMethods.rb', line 33 def wait_no_element(element, timeout_duration: 15, sleep_duration: 0, retry_frequency: 0.3) wait_for_element_does_not_exist(element, timeout: timeout_duration, retry_frequency: retry_frequency) sleep(sleep_duration) end |