Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created October 15, 2019 14:21
Show Gist options
  • Save twalpole/a23d11af2f747f4a0d906fc58129e5b2 to your computer and use it in GitHub Desktop.
Save twalpole/a23d11af2f747f4a0d906fc58129e5b2 to your computer and use it in GitHub Desktop.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'capybara', '3.29.0'
gem 'puma'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'byebug'
end
require 'selenium-webdriver'
require "capybara/dsl"
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
%i[selenium_chrome selenium_chrome_headless].each do |driver|
puts "Using #{driver}"
sess = Capybara::Session.new(driver, app)
sess.visit('/')
sess.click_button("myfoo")
end
__END__
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello!</title>
</head>
<body>
<form method="GET" action="">
<button id="myfoo">Foo</button>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment