Skip to content

Instantly share code, notes, and snippets.

@mattwynne
Forked from jarib/test.rb
Created August 28, 2012 13:46
Show Gist options
  • Save mattwynne/3498129 to your computer and use it in GitHub Desktop.
Save mattwynne/3498129 to your computer and use it in GitHub Desktop.
File.open("test.html", "w") { |file| file << "<h1>hello</h1>" }
url = "file://#{File.expand_path '../test.html', __FILE__}"
require 'capybara'
browser = Capybara::Session.new(:selenium)
browser.visit url
puts browser.find("h1").text
File.open("test.html", "w") { |file| file << "<h1>hello</h1>" }
url = "file://#{File.expand_path '../test.html', __FILE__}"
require 'selenium-webdriver'
browser = Selenium::WebDriver.for :firefox
begin
browser.get url
puts browser.find_element(:tag_name => "h1").text
ensure
browser.quit
end
@mattwynne
Copy link
Author

The test-capybara script fails with Capybara 1.1.2 (on my machine at least) but it does pass on Capybara 2.0.0 beta2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment