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()?


In reply to How to get javascript to exectue when clicking a button in IEAutomation? by rizzy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.