Skip to content

Instantly share code, notes, and snippets.

@abotalov
Last active August 29, 2015 14:03
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 abotalov/19f6f07b2d9cc64f8a59 to your computer and use it in GitHub Desktop.
Save abotalov/19f6f07b2d9cc64f8a59 to your computer and use it in GitHub Desktop.
require 'capybara'
require 'benchmark'
html = DATA.read
$app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
session = Capybara::Session.new(:selenium, $app)
session.visit("/")
puts "Capybara text: #{session.all('div').map { |el| el.text.codepoints }}" # => [[97, 32, 98], [97, 32, 98], [97, 32, 98]]
puts "Wedbriver text: #{session.all('div').map { |el| el.native.text.codepoints }}" # => [[97, 32, 98], [97, 32, 32, 32, 32, 98], [97, 8194, 8194, 8194, 8194, 98]]
__END__
<!doctype html>
<html>
<body>
<div class="space tab lf">a
b</div>
<div class="non_breaking_space">a&nbsp;&nbsp;&nbsp;&nbsp;b</div>
<div class="U+2001">a&ensp;&ensp;&ensp;&ensp;b</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment