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

I have a script that accesses our website, hosted by a 3rd party. I am using Mechanize::Firefox. The script proceeds successfully thru each screen, entering some data into fields, and clicking a button to go to the next screen. Finally, I arrive at the last screen which is a table, built by javascript, that contains multiple rows of items, any of which can be clicked on to get the detail screen for that item. My problem is I don't know how to click on a table item.

here is the snapshot of the Firebug window:

<table id="tbListResults" width="100%" cellspacing="0" cellpadding="0" + border="0"> <tbody> <tr> <td id="tdList" style="height: auto"> <table width="100%" cellspacing="0" cellpadding="2" border="0"> <tbody> <tr> <tr class="listitem"> <td onclick="selectListItem(3348956)"> <b>CC026836</b> </td> <td onclick="selectListItem(3348956)"> <td onclick="selectListItem(3348956)"> <td onclick="selectListItem(3348956)">TSX/TECHNOLOGY PKG NAVIGATION SU +NROOF LEATHER HEATED SEATS REAR CAMERA ALL POWE</td> <td onclick="selectListItem(3348956)">Basque Red Pearl</td> <td onclick="selectListItem(3348956)">JH4CU2F62CC026836</td> <td onclick="selectListItem(3348956)">Certified Autoplex(27)</td> <td onclick="selectListItem(3348956)">Available</td> <td align="right" onclick="selectListItem(3348956)">$21,996.00</td> <td align="right" onclick="selectListItem(3348956)">13074</td> <td align="center" onclick="selectListItem(3348956)">0</td> <td align="center"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>

Replies are listed 'Best First'.
Re: click on an row in a table using Mechanize::Firefox
by billg68 (Initiate) on Dec 21, 2015 at 01:13 UTC

    Never mind perlmonks, I finally figured it out.

    my $veh_btn = '/html/body/div/div[4]/div[1]/form/div[7]/table[3]/tbody +/tr/td/table/tbody/tr[2]/td[1]'; @divs = $mech->xpath( $veh_btn ); $mech->click( { dom => $divs[0], synchronize => 0 } ); if ($mech->success()) { print "\n Success, we clicked the detail screen!\n"; Win32::Sound::Play("ding.wav"); Win32::Sound::Stop(); };