Created
February 9, 2015 14:50
-
-
Save joey-g/dab3f9468fabffe2d27b to your computer and use it in GitHub Desktop.
Script for pulling window.bt.listings.models attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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