Watir Hint for Working with ImageButtons

Dustin, one of my co-workers, ran into a problem accessing the "alt" attribute on image buttons using Watir and discovered a useful trick:

Who knows if this will ever be useful to anyone else, but I've been trying to work with imageButtons, which have alt tags. In HTML they render as <input type="image".../> I wanted to access the alt tag of the image. ie.contains_text wouldn't find it for me. Only image objects in watir have any knowledge of alt tags.  And unfortunately, watir recognizes imageButtons, not as images, but as buttons.
there is almost no documentation that covers this, but I found that even though these are buttons, you can use image methods to manipulate these 'buttons'. For example, you can get the object with:
  • button = $ie.button(:alt, "This is the alt text...") *alt is only exposed for images, but works for imageButtons.
And you can manipulate the buttons with image methods, such as:
  • button.exists?
Published Tuesday, September 20, 2005 1:11 PM by iclemartin
Filed under:

Comments

# re: Watir Hint for Working with ImageButtons

just ensure that the developers always specify the alt attribute and testing becomes easy

Monday, October 03, 2005 11:33 AM by It works

# re: Watir Hint for Working with Frames

Not able to identity images which is nested inside a frames. Used src parameter to identify it.

Friday, January 05, 2007 1:02 AM by Meena

Leave a Comment

(required) 
(required) 
(optional)
(required)