Skip to content

Instantly share code, notes, and snippets.

@twalpole
Last active July 29, 2019 16:09
Show Gist options
  • Save twalpole/4084690d90cc4beac28fcebf887cb6c1 to your computer and use it in GitHub Desktop.
Save twalpole/4084690d90cc4beac28fcebf887cb6c1 to your computer and use it in GitHub Desktop.
Ancestor test for Capybara issue
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'selenium-webdriver', '3.142.3'
gem 'webdrivers'
gem 'capybara', '3.27.0'
gem 'byebug'
gem 'puma'
end
require 'webdrivers'
require "capybara/dsl"
require 'byebug'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:selenium_chrome, app)
sess.visit("/")
sess.find('.dc-multi-level-selector-item-label', text: 'Urgence').ancestor('.dc-multi-level-selector-item')
__END__
<!doctype html>
<html>
<head>
<title>Some title</title>
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
</head>
<body>
<div class="dc-multi-level-selector-item cursor-pointer">
<span class="dc-checkbox dc-multi-level-selector-item-checkbox"></span>
<div class="dc-multi-level-selector-item-content">
<span class="dc-multi-level-selector-item-label">Urgence</span>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment