Skip to content

Instantly share code, notes, and snippets.

@scottwillson
Created April 6, 2012 21:09
Show Gist options
  • Save scottwillson/2322957 to your computer and use it in GitHub Desktop.
Save scottwillson/2322957 to your computer and use it in GitHub Desktop.
def wait_until_visible(locator, seconds = 10)
raise ArgumentError if locator.blank?
begin
Timeout::timeout(seconds) do
until page.has_css?(locator) && find(locator).visible?
sleep 0.25
end
end
rescue Timeout::Error => e
fail "'#{locator}' did not appear within #{seconds} seconds"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment