There was recently a question on Stack Overflow about how you read a CSS property of an element that is defined in a stylesheet using Watir-WebDriver.
It’s really quite simple:
require 'watir-webdriver' b = Watir::Browser.start 'minesweeper.github.com' puts b.div(:id => 'g1minesRemaining100s').style 'background-image'
Thanks for pointing me for this triick, and to that good MineSweeper implementation too :-)
It is great to use style attribute to verify an element’s style. However, I just found an annoying issue. Different browsers may return slightly different values.
For example, for the same element,
Firefox and IE return the color style like ‘rgba(51,51,51,1)’
Chrome returns the color style like ‘rgb(51, 51, 51)’
I have to add some very ugly browser type check logic in my library or step definition. :-(
Does anybody have an idea to handle this issue?