watir advanced xpath onclick example
problem space:
you are trying to click a (click-able) link element, with no real discerning qualities. (i.e. there is no name, no id, a generic css class same as the other links on the page, etc. Luckily, In this case there is a javascript onclick handler which is unique to this element.
<a class="showhide" href="javascript:void(0)" onclick="setDisplay('notes','block');">show
you could accomplish this two ways. (that I know of)
1. find the number of the link in relation to the page, (i.e. it's the 13th)
ie.link(:index, 13).click
2. specify an xpath.
ie.link(:xpath, "//a[contains(@onclick, \"setDisplay('notes','block')\")]").click
(I just also, 'discovered' that firebug (Firefox JavaScript debugging extension) offers an xpath to elements, (in the right click). it offered this: (untested)
/html/body/div[2]/table/tbody/tr/td/table/tbody/tr/td/div/form/table/tbody/tr/td/div[2]/table[7]/tbody/tr[3]/td/a

I was looking around because I also have a page with a bunch of href="javascript:void(0)" buttons, and watir has this ability
Button code -
(All the buttons went to different sites)
This code got me what I needed
ie.button(:value, "Click Me!").fire_event("onclick")
@AJ
Button Code:
input type=text value="Click Me!" onClick="redirect_user('http://google.com')"
@AJ
Thanks for posting, I haven't used 'fire_event', good to keep in mind