Created
May 9, 2016 14:19
-
-
Save jnicklas/a2ada84190f2cc9fdb95acec6a235dde to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require "capybara" | |
html = DATA.read | |
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] } | |
sess = Capybara::Session.new(:selenium, app) | |
sess.visit("/") | |
sess.click_link("Click me") | |
sess.reset! | |
__END__ | |
<!doctype html> | |
<html> | |
<body> | |
<a href="/foo">Click me</a> | |
<script> | |
window.addEventListener("beforeunload", function(event) { | |
if(!confirm("are you sure?")) { | |
event.preventDefault(); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment