Skip to content

Instantly share code, notes, and snippets.

@BiggerNoise
Created July 1, 2013 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BiggerNoise/5897770 to your computer and use it in GitHub Desktop.
Save BiggerNoise/5897770 to your computer and use it in GitHub Desktop.
Trying to demonstrate an issue that I am having when running capybara with a page that has an on document ready callback
require "capybara"
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:selenium, app)
sess.visit("/")
puts 'You Lose' unless sess.has_content? 'Here it Is'
puts sess.html
__END__
<!doctype html>
<html>
<head>
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
</head>
<body>
<p id="target"></p>
<div id="data" data-sample="Here it Is"></div>
<script>
$( function() {
$('#target').text($('#data').data('sample'))
}
)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment