Created
December 18, 2013 23:48
-
-
Save jmoody/8031882 to your computer and use it in GitHub Desktop.
calabash wait for view with point to disappear
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def view_at_point?(point, view_class='view') | |
res = query(view_class) | |
res.each { |view_hash| | |
center = {:x => view_hash['rect']['center_x'], :y => view_hash['rect']['center_y']} | |
return true if center == point | |
} | |
false | |
end | |
def wait_for_view_at_point_to_disappear(point, opts={}) | |
default_opts = {:view_class => 'view', | |
:timeout => 14, | |
:post_timeout => 0.4, | |
:retry_frequency => 0.1} | |
opts = default_opts.merge(opts) | |
if opts[:timeout_message].nil? | |
timeout = opts[:timeout] | |
msg = "waited for '#{timeout}' sec but view with center point '#{point}' did not disappear" | |
opts[:timeout_message] = msg | |
end | |
wait_for(opts) do | |
not view_at_point?(point, opts[:view_class]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment