Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created July 11, 2017 00:16
Show Gist options
  • Save twalpole/6f549a27916b1fa2a8d4ef23677f58b2 to your computer and use it in GitHub Desktop.
Save twalpole/6f549a27916b1fa2a8d4ef23677f58b2 to your computer and use it in GitHub Desktop.
require 'capybara/dsl'
require 'capybara/poltergeist'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:poltergeist, app)
sess.visit('/')
btn = sess.find('#submit_payment')
puts btn[:disabled]
sess.save_and_open_screenshot
sess.click_button('Enable')
sleep 0.5
puts btn[:disabled]
sess.save_and_open_screenshot
__END__
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
</head>
<body>
<button id="submit_payment" disabled>Blah</button>
<button type="button" onclick="$('#submit_payment').prop('disabled', false)">Enable</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment