Skip to content

Instantly share code, notes, and snippets.

@jmoody
Created December 18, 2013 23:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmoody/8031882 to your computer and use it in GitHub Desktop.
Save jmoody/8031882 to your computer and use it in GitHub Desktop.
calabash wait for view with point to disappear
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