Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Perl Mechanize firefox Click issue

by vkknava (Novice)
on Feb 22, 2016 at 14:39 UTC ( [id://1155815]=perlquestion: print w/replies, xml ) Need Help??

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

I have written a code to automate my webpage to do a search and download a report. Till selection of the report everything works fine. But download click is not working after clicking checkbox. It works well if i keep the download click bust before checkbox select. But I need to select the reports to click download.

<form action="xxx.net:1234/xxx/xxx/abc.do?starttrail=true&advancedSear +ch=true" onsubmit="javascript:deleteReport(this);"> <input type="hidden" name="formAction" id="formAction"/> <table id="reportLog" class="content" cellspacing="0" cellpadding="0"> <tr> <th class="actionHeader" colspan="5"> <div class="leftButtons"> <input type="button" id="deleteButton" name="delet +e" value='Delete' height="5" /> <input type="button" id="downloadButton" name="dow +nload" value='Download' height="5" /> </div> </th> </tr> <tr> <th class="column checkbox"><input type="checkbox" name="selectAll" + onClick='javascript:checksOnlyActive(this.checked, this.form, "selec +tedLogs")'/></th> </tr> <tr> <td class="checkboxCol "> <input type="checkbox" name="selectedLogs" value='178746' /></td> <td >Complete</td> <td >def</td> <td >123abc</td> <td nowrap> Feb 14, 2016 1:31 PM </td> </form>

here is the perl code.

#! C:/Perl64/bin/perl.exe use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(); my $url = 'login_path'; my $url_2 = 'search_tab_path'; sub print_status() { my $status =$mech->status(); print "status = $status\n"; } $mech->get($url, activate => 1, autoclose => 0, js_JSON => 'native'); print_status(); my $username = 'aaa'; my $password = 'bbb'; $mech->form_name('logonForm') ; $mech->field ('username' => $username); $mech->field ('password' => $password); #print_status(); $mech->click({ xpath => '//*[@value="Login"]' }); #print_status(); $mech->get($url_2); $mech->form_name("reportLogCatalogForm"); $mech->field('searchV','vkknava'); $mech->click({ xpath => '//*[@id="searchButton"]' }); #$mech->click({ xpath => '//input[@onclick]',synchonize => 0 }, 1) +; my $l = $mech->xpath('//input[@onclick]', single => 1); $mech->synchronize('DOMFrameContentLoaded', sub { $l->__click() }); $mech->click({ xpath => '//*[@id="downloadButton"]',synchonize => 0 }) +;

Somebody is expertise here?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-24 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found