Skip to content

Instantly share code, notes, and snippets.

@leshill
Forked from leosoto/gist:434460
Created June 12, 2010 13:25
Show Gist options
  • Save leshill/435736 to your computer and use it in GitHub Desktop.
Save leshill/435736 to your computer and use it in GitHub Desktop.
def javascript_confirm(answer)
page.evaluate_script 'window._confirm = window.confirm'
page.evaluate_script "window.confirm = function(x) { return #{answer} }"
yield
page.evaluate_script 'window._confirm && (window.confirm = window._confirm)'
page.evaluate_script 'window._confirm = null'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment