# WATIR - Clicking img

**URL:** <https://www.ruby-forum.com/t/watir-clicking-img/114430>\
**Category:** Ruby\
**Created:** [September 12, 2007, 5:09pm UTC](https://www.ruby-forum.com/t/watir-clicking-img/114430 "2007-09-12T17:09:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tracyp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed655f/32.png) [@tracyp](https://www.ruby-forum.com/u/tracyp)\
**Post date:** [September 12, 2007, 5:09pm UTC](https://www.ruby-forum.com/t/watir-clicking-img/114430/1 "2007-09-12T17:09:43Z")

</div>

This is driving me up the wall.

I need to click on an apply button, however the Javascript has a number  
of hidden buttons. You would think the developer would identify each one  
uniquely but he hasn’t. Each one is:

the only difference is the onClick bit.

Any ideas as to how I can click this damn button?

I’ve tried numerous things so any help would be appreciated.

Thanks  
Tracy

---

<div class="post-metadata">

**Author:** ![tracyp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed655f/32.png) [@tracyp](https://www.ruby-forum.com/u/tracyp)\
**Post date:** [October 6, 2007, 10:58pm UTC](https://www.ruby-forum.com/t/watir-clicking-img/114430/2 "2007-10-06T22:58:52Z")

</div>

I’m not sure if this a great way of doing it, but I overrode the link  
method  
to add the :html search type:

class IE  
def getLink( how, what )  
[… normal code …]  
when :html  
links.each do |thisLink|  
if what.matches(thisLink.outerHtml)  
link = thisLink if link == nil  
end  
end  
[… rest of method …]  
This searches based on outer html. This could be used to find your link  
based on contents in the onClick:

@ie.link(:html, /value=‘New’/).flash

/Shawn
