Skip to content

Instantly share code, notes, and snippets.

@joey-g
Created February 9, 2015 14:50
Show Gist options
  • Save joey-g/dab3f9468fabffe2d27b to your computer and use it in GitHub Desktop.
Save joey-g/dab3f9468fabffe2d27b to your computer and use it in GitHub Desktop.
Script for pulling window.bt.listings.models attributes.
# Helper for accessing window.bt.listings.models object on page. Uses detail_attribute
# param to access specific field on found property's details object.
def property_detail_attribute(detail_attribute)
detail_script = <<-CMD
matched_property =
$.grep(window.bt.listings.models,
function(m) {
return m.id == #{@property_id};
})[0];
if (matched_property) {
return matched_property.attributes.#{detail_attribute};
} else {
return null;
}
CMD
detail_result = @browser.execute_script(detail_script)
if not detail_result.nil?
return detail_result
else
raise "No #{detail_attribute} attribute was found for property with id: #{@property_id}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment