Skip to content

Instantly share code, notes, and snippets.

@abotalov
Created July 2, 2014 21:37
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/df3630771e21bae504c8 to your computer and use it in GitHub Desktop.
Save abotalov/df3630771e21bae504c8 to your computer and use it in GitHub Desktop.
require 'capybara'
require 'benchmark'
html = DATA.read
$app = proc { |env| [200, { "Content-Type" => "text/xml" }, [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__
<?xml version="1.0" encoding="UTF-8"?>
<el>
<div class="space tab lf">a
b</div>
<div class="non_breaking_space">a&#xa0;&#xa0;&#xa0;&#xa0;b</div>
<div class="U+2001">a&#8194;&#8194;&#8194;&#8194;b</div>
</el>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment