http://qs1969.pair.com?node_id=944794

mmittiga17 has asked for the wisdom of the Perl Monks concerning the following question:

Trying to click a link using the following method: HTML code below as well. When I view source I see the link but can not click on it. Thanks for looking.

$ie->getLink('id:', "ctl00_ContentPlaceHolder2_ctrlPageHeader1_aFilter +")->Click(1);
<A style="TEXT-DECORATION: none" id=ctl00_ContentPlaceHolder2_ctrlPageHeader1_aFilter class=RightTextHeading onclick="javascript:openMdlWindow('InvestmentDetailOptions.aspx?IDAssetType=','620','600');if(window.document.RetValue == '2'){window.parent.LoadinIframe('InvestmentDetail.aspx?FromMenu=N&amp;IDAssetType=','Investment Details > Full View','false');}">Filter</A>

Replies are listed 'Best First'.
Re: Win32::IEAutomation click link help
by Anonymous Monk on Dec 23, 2011 at 00:25 UTC

      An additional problem with the html , since Win32::IEAutomation::getLink uses  $agent->Document->links, but InternetExplorer.Application doesn't consider an A element without a href attribute a link, its not listed under  ->links.

      The DOM method getElementById() will find it , but naturally it won't do anything, since "javascript:" in an onclick attribute is an error

      I get this error: Can't call method "Click" on an undefined value at C:\lab\nbt3.pl line 56. and it does not show up as a link due to no href tag. I will check the additional information you provided links to. thanks!

        found solution by editing the the win32::IEAutomaiton module. addeded the below.

        sub getLink2{ my ($self, $how, $what) = @_; my $agent = $self->{agent}; #my $links = $agent->Document->links; my $links = $agent->Document->all->tags("a"); my $target_link = __getObject($links, $how, $what) if ($links); my $link_object; if ($target_link){ $link_object = Win32::IEAutomation::Element->new(); $link_object->{element} = $target_link; $link_object->{parent} = $self; }else{ $link_object = undef; print "WARNING: No link is present in the document with your +specified option $how $what\n" if $warn; } return $link_object; }