Skip to content

Instantly share code, notes, and snippets.

@gdakram
Created August 6, 2015 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdakram/44c5a309f1371906f2d6 to your computer and use it in GitHub Desktop.
Save gdakram/44c5a309f1371906f2d6 to your computer and use it in GitHub Desktop.
# Try to tap the screen until view open on screen
# x:: starting x value
# y:: starting y value
# x_delta:: Value to change in x direction
# y_delta:: Value to change in y direction
# query:: query to wait for the view
# number_of_tries:: number of tries
def touch_element_by_moving(x, y, x_delta, y_delta, query, number_of_tries=5)
i = 0
begin
performAction('touch_coordinate', x, y)
wait_for_elements_exist([query], {:timeout => 3})
wait_for_loading_spinner_disappear
sleep(STEP_PAUSE)
return true
rescue
x, y, i = x+x_delta, y+y_delta, i+1
retry if i <= number_of_tries
end
return false
end
# And call this function, to tap the link
element = query("TextView id:'register_footer'").first
x = element['rect']['x']
y = element['rect']['y']
screenshot_and_raise('terms and condition link not touched') unless touch_element_by_moving(x, y, -20, 0,"webView css:'*'",5)
# You can start x and y from the beginning or from the middle ( element['rect']['center_x'], element['rect']['center_y'] based on link located on TextView.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment