Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

How to get javascript to exectue when clicking a button in IEAutomation?

by rizzy (Sexton)
on May 18, 2012 at 17:17 UTC ( #971342=perlquestion: print w/replies, xml ) Need Help??
rizzy has asked for the wisdom of the Perl Monks concerning the following question:

I am using `Win32::IEAutomation` in perl to fill in a form and search, but when I use getButton()->Click I get the error "Can't call method "Click" on an undefined value". I am able to click an image (which executes javascript), but not the button.

I noticed in the documentaion for Win32::IEAutomation that it says the following under both "getImage" and "getLink", but NOT under "getButton":

"As it uses click method of DOM, it supports clicking link with javascript in it."

Can anyone tell me how to click the button and fire the javascript?

Here is a skeleton of my code. The final line is the one that gives me trouble.:

use Win32::IEAutomation; my $ie = Win32::IEAutomation->new( visible => 1); $ie->gotoURL('',1); $ie->getTextBox('id:', "mytextbox")->SetValue("relevant text"); $ie->getButton('id:', "mybutton")->Click;

and here is the relevant part of the html:

<input type="text" id="mytextbox" /> <button id="mybutton" title="Go" class="ControlButton" value="Go" +onclick="researchLookupObj.GoClick(CallServer);return false;">Search< +/button>

I am able to get the textbox to fill in (and am able to click on an image earlier in the code which is not shown here), but get the error with the button. How can I tell it to execute the javascript named researchLookupObj.GoClick()?

Replies are listed 'Best First'.
Re: How to get javascript to exectue when clicking a button in IEAutomation?
by Anonymous Monk on May 18, 2012 at 19:09 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://971342]
Approved by Corion
and !@monks...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2017-02-22 01:59 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (322 votes). Check out past polls.