invoke javascript by clicking an image

G

Go Ma

I am newbie to Ruby so pl pardon my ignorance.

I have an image in a web page which has the following code:

<img style = "cursor: hand",
onclick="javascript:fnC20WebCtrlOpenCtrlChangeProjectWindow(this,event,3,0,'1022','');

Can someone please suggest how to click this image (basically, invoke
the javascript) using Ruby?? Tried searching the net but hadn't had much
luck.
 
B

Brian Candler

Go said:
I am newbie to Ruby so pl pardon my ignorance.

I have an image in a web page which has the following code:

<img style = "cursor: hand",
onclick="javascript:fnC20WebCtrlOpenCtrlChangeProjectWindow(this,event,3,0,'1022','');

Can someone please suggest how to click this image (basically, invoke
the javascript) using Ruby?? Tried searching the net but hadn't had much
luck.

If you want to control a browser programatically using Ruby, have a look
at Watir: http://watir.com/

Another option is Selenium.
 
D

David Masover

I am attaching the relevant code I
could view using IEDev bar.

Wait, why are you attaching this as a screenshot? Shouldn't you be able to
just provide source, as text? Or better yet, a URL to the page in question?

Better still, give us a simplified example -- a small HTML page that does
nothing other than demonstrate the problem.

http://www.catb.org/~esr/faqs/smart-questions.html#volume

Screenshot... docx. You do realize those don't go together, don't you? If it's
an image, attach an image -- png, jpeg, even bmp would work. Not all of us
have (or want) MS Word.

http://www.catb.org/~esr/faqs/smart-questions.html#formats
 
B

Brian Candler

Go said:
Thanks a lot for your prompt note. I actually started off with Watir,
but got stuck with the above issue.

Then your question should be: "in Watir, how do I click on an image that
has a javascript onclick handler?"

That question would be best directed to a Watir forum. I also suggest
that you will get a better answer there if you post the ruby code that
you already tried but failed. Also show what relevant items you found in
the Watir documentation and/or source code and/or from googling, and why
it didn't help you solve the problem.
I am attaching the relevant code I
could view using IEDev bar. Any help would be appreciated!!

You didn't paste any code (Ruby or JS) whatsoever. You pasted a document
containing a screenshot of some HTML.

I *was* able to open that docx file with OpenOffice, but you should be
aware that if you make life difficult for the people you are asking for
help, then they're not going to be inclined to.

However, I am not a Watir expert anyway, so the best I can offer is to
try again in a Watir forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,041
Members
47,634
Latest member
Alba16710

Latest Threads

Top