Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created July 23, 2018 16:31
Show Gist options
  • Save twalpole/a71ec27599f0f7810c553a0df043b377 to your computer and use it in GitHub Desktop.
Save twalpole/a71ec27599f0f7810c553a0df043b377 to your computer and use it in GitHub Desktop.
require "capybara/dsl"
require 'selenium/webdriver'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:selenium_chrome, app)
sess.visit('/')
div1 = sess.find('#div1')
div2 = sess.find('#div2')
puts div1.matches_css?('div.a')
puts div2.matches_css?('div.a')
__END__
<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
<div id="div1" class="a b c">Div 1</div>
<div id="div2" class="b c">Div 2</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment