我正在尝试编写一个 watir webdriver 脚本来检索元素的属性,然后获取它们的值。给定元素
<input id="foobar" width="200" height="100" value="zoo" type="text"/>
希望我可以做以下事情:
testElement = $b.element(:id, "foobar")
testElement.attributes.each do |attribute|
puts("#{attribute}: #{testElement.attribute_value(attribute)}")
end
我希望得到
id: foobar
width: 200
height: 100
value: zoo
type: text