I am trying to write a watir webdriver script which retrieves the attributes of an element and then gets their values.
given element
<input id="foobar" width="200" height="100" value="zoo" type="text"/>
hoping that I can do something like the following:
testElement = $b.element(:id, "foobar")
testElement.attributes.each do |attribute|
puts("#{attribute}: #{testElement.attribute_value(attribute)}")
end
I would hope to get
id: foobar
width: 200
height: 100
value: zoo
type: text
I have seen people using javascript to get the list of attributes. The following shows how you could add a method to Watir::Element to get the list of attributes (though extending Watir is optional).