Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created August 12, 2019 21:15
Show Gist options
  • Save twalpole/c42334f9bfeee30b3f7248b414e3d55a to your computer and use it in GitHub Desktop.
Save twalpole/c42334f9bfeee30b3f7248b414e3d55a to your computer and use it in GitHub Desktop.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'selenium-webdriver', '3.142.3'
gem 'webdrivers'
gem 'capybara', '3.28.0'
gem 'puma'
gem 'rspec'
gem 'pry'
gem 'pry-byebug'
end
require 'webdrivers'
require "capybara/dsl"
require 'capybara/rspec'
require "rspec/autorun"
require 'byebug'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
Capybara.app = app
Capybara.default_driver = :selenium
# sess = Capybara::Session.new(:selenium, app)
RSpec.describe "some tests", type: :feature do
it "can use has_select?" do
page.visit("/")
# binding.pry
expect(page.has_select?('my_select', selected: '2')).to eq true
expect(page).to have_select('my_select', selected: '2')
end
end
__END__
<!doctype html>
<html>
<head>
<title>Some title</title>
</head>
<body>
<div id="company_logos">
<div id="first_logo">
<div id="inside">Blah Blah Blah</div>
</div>
<div id="container">
<div id="other">
<select id="my_select">
<option>1</option>
<option selected>2</option>
<option>3</option>
</select>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment