watir-webdriver: Validating the Color of an element

309 views
Skip to first unread message

hillary

unread,
Aug 8, 2011, 2:34:19 PM8/8/11
to watir-...@googlegroups.com
When there's an error, the application i'm testing changes the color of the element, a text_field, changes to red. Currently I validate that the text_field is red like this: 
b.text_field(:id, "text_field").document.currentstyle.color.should == '#444' 

I also will did to validate the color of a div message that tells the user that changes have been saved. i use the document.currentstyle.color for this also. 

Thanks. 

Jari Bakken

unread,
Aug 8, 2011, 2:43:42 PM8/8/11
to watir-...@googlegroups.com
WebDriver doesn't give direct access 

Jari Bakken

unread,
Aug 8, 2011, 2:45:49 PM8/8/11
to watir-...@googlegroups.com
WebDriver doesn't give direct access to the underlying DOM object like other implementations. Instead you can use b.text_field(:id, "text_field").style("color"). 


Den 8. aug. 2011 kl. 20:34 skrev hillary <weima...@gmail.com>:

--

hillary

unread,
Aug 8, 2011, 3:38:25 PM8/8/11
to watir-...@googlegroups.com
Thanks. 

Just to confirm, the color would be it's html value (#444), so it'd be .style("#444")? 

Jari Bakken

unread,
Aug 8, 2011, 3:46:20 PM8/8/11
to watir-...@googlegroups.com
No, .style returns the value of the given CSS property. So .style("color").should == "#444". 


Den 8. aug. 2011 kl. 21:38 skrev hillary <weima...@gmail.com>:

Thanks. 

Just to confirm, the color would be it's html value (#444), so it'd be .style("#444")? 

--

hillary

unread,
Aug 8, 2011, 3:52:26 PM8/8/11
to watir-...@googlegroups.com
Okay. Thanks. 
Reply all
Reply to author
Forward
0 new messages