Hi All,

INFO - this question has also been posted on Stackoverflow.com

I have a button in a website I can't work out how to press. It's not in a form so mechanize doesn't work, I've tried IEAutomation. I'm working with IE 10 and chrome so mechanize::firefox isn't an option. Trying to click the button on the line marked with (*)

The solution needs to be in perl (so it can be called from inside another application).

<html> <head> </head> <body> <table> <tr> <td> <td> <table> <tr> <td> <!-- start of toolbar Main --> <table> <tr> <td> <table> <tr class="buttonPad"> </tr> <tr> (*) <td nowrap="true" valign="top" class="button"><a id=" +S7674" accesskey="S" class="button" title="SEARCH" onclick="dispatch( +'S7674');"><u>S</u>></td> </tr> </table> </td> <td</td> </tr> </table> </td> </tr> </table> </td> </td> </tr> </table> </body> </html>

Here's what I have:

my $content = get($funky); my $tree = HTML::Tree->new(); $tree->parse($content); my ($title) = $tree->look_down( '_tag' , 'a' ); my $atag = ""; foreach $atag ( $tree->look_down( _tag => q{a}, 'class' => 'button +', 'title' => 'SEARCH' ) ) { print $atag->attr('id'), "\n"; } my $ie = Win32::IEAutomation->new( visible => 0, maximize => 0); $ie->gotoURL($funky); $ie->getButton('id:', $atag )->Click();

I get "Can't call method "Click" on an undefined value". Anyone got a bright idea? Cheers Micro


In reply to web automation button clicking problems by MicrobicTiger

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.