Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created May 30, 2012 14:58
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save metaskills/2836849 to your computer and use it in GitHub Desktop.
Save metaskills/2836849 to your computer and use it in GitHub Desktop.
Basic Save & Open Page For Poltergeist
def save_and_open_page
dir = "#{Rails.root}/tmp/cache/capybara"
file = "#{dir}/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png"
FileUtils.mkdir_p dir
page.driver.render file
wait_until { File.exists?(file) }
system "open #{file}"
end
@loveybot
Copy link

Yay Ruby!!

Copy link

ghost commented May 27, 2014

wait_until has been removed from capybara.

Copy link

ghost commented May 27, 2014

while !File.exists?(file) do
  sleep 1
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment