vivek.vivek 0 Light Poster

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="" 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="delete" value='Delete' height="5"  /> <input type="button" id="downloadButton" name="download" value='Download' height="5" /> </div> </th> </tr> <tr> <th class="column checkbox"><input type="checkbox" name="selectAll"  onClick='javascript:checksOnlyActive(this.checked, this.form, "selectedLogs")'/></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>

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";

              activate  => 1,
              autoclose => 0,
              js_JSON   => 'native');

    my $username = 'aaa'; 
    my $password = 'bbb';

    $mech->form_name('logonForm') ;
    $mech->field ('username' => $username);
    $mech->field ('password' => $password);
    $mech->click({ xpath => '//*[@value="Login"]' });
    $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 {
$mech->click({ xpath => '//*[@id="downloadButton"]',synchonize => 0 });

I have copied only a part of the html code (without JS functions). I cannot change the html as it is generated from a 3rd party tool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.