Watir: Get document detail information in Watir.

ie.#{element}(:id,"foo").document.currentstyle.attributeAsCamelCase
so
ie.#{element}(:id,"foo").document.currentstyle.fontFamily
ie.#{element}(:id,"foo").document.currentstyle.fontSize
ie.#{element}(:id,"foo").document.currentstyle.color
Sometimesyou have to use invoke: 
ie.#{element}(:id,"foo").document.currentstyle.invoke(attributeAsCamelCase)
thevisible method works this way:
ie.#{element}(:id,"foo").document.currentstyle.invoke("display")
ie.#{element}(:id,"foo").document.currentstyle.invoke("isDisabled")

Find the list of available methods:

ie.#{element}(:id,"foo").document.currentstyle.ole_methods

#puts ie.div(:class,/TopbackgroudTopFont/).document.currentstyle.fontSize

#puts ie.div(:class,/TopbackgroudTopFont/).document.currentstyle.color

#puts ie.div(:class,/TopbackgroudTopFont/).document.currentstyle.backGroundColor

#puts ie.div(:class,/TopbackgroudTopFont/).document.currentstyle.scrollbarBaseColor

Get class name by

puts ie.span(:text,/running/i).class_name

Get the _eventID attribute by:

puts ie.span(:text,/running/i).document.getAttribute("_eventID")
puts $ie.div(:id,"workout_29251129").document.getAttributeNode('_eventID').value

or

puts ie.span(:text,/running/i).attribute_value("_eventID")
原文地址:https://www.cnblogs.com/autotest/p/3262417.html