Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created September 26, 2018 21:13
Show Gist options
  • Save twalpole/7510d1946b11df9096738b9e9687ec64 to your computer and use it in GitHub Desktop.
Save twalpole/7510d1946b11df9096738b9e9687ec64 to your computer and use it in GitHub Desktop.
html = DATA.read
require "selenium-webdriver"
require "capybara/dsl"
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:selenium_chrome, app)
sess.visit('/')
tile = sess.find(:css, "deep-tile[test-id='property_data.smart_home_starter_kit.']")
if tile.has_css?('div', class: ['tile-wrapper', 'selected'])
puts 'selected'
elsif tile.has_css?('div', class: ['tile-wrapper', '!selected'])
puts 'not selected'
else
puts 'not found'
end
__END__
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<deep-tile ng-repeat="tile in page.tiles" test-id="property_data.smart_home_starter_kit." field="tile" data="data.leadData" on-event="deepTileEvent($event)" class="ng-scope ng-isolate-scope">
<div class="tile-wrapper blue background- selected" ng-class="{'selected':isSelected()}">
<div class="tile" ng-class="{'hovered': hovered}" ng-mouseover="hovered = true" ng-mouseout="hovered = false" ng-click="click();">
<!-- ngIf: field.checkbox --><div ng-if="field.checkbox" class="tile-select ng-scope"><i class="material-icons">done</i></div><!-- end ngIf: field.checkbox -->
<div class="tile-icon "><span class="hippo-icon-sensor" alt="Smart Home Device"></span></div>
<div class="tile-info">
<p class="title ng-binding">Smart Home Device</p>
<p class="info ng-binding" ng-bind-html="::field.bodyHtml|trustAsHtml">Complimentary kit provided to you by Hippo after you complete your purchase. Activate within 60 days to maintain your discount</p>
<!-- ngIf: ::field.footer -->
<!-- ngIf: field.actionLabel -->
<!-- ngIf: field.info --><span class="info-icon ng-scope" ng-if="field.info"><div ng-click="infoClicked($event)"><img src="/img/info.svg?v=1537945883723" alt="More Info"></div></span><!-- end ngIf: field.info -->
</div>
</div>
</div>
</deep-tile>
<body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment