Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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('https://www.mywebpage.com/index.html',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()?

Comment on How to get javascript to exectue when clicking a button in IEAutomation?
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://971342]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-09-17 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (53 votes), past polls