MicrobicTiger has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|