Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Elusive button WWW::Mechanize::Firefox

by jjap (Monk)
on Aug 11, 2012 at 01:16 UTC ( #986845=perlquestion: print w/ replies, xml ) Need Help??
jjap has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to get the hang of some automation with WWW::Mechanize::Firefox and can get as far as entering data in a form in what I think is a very simple case.

I tried various ways to activate/click/submit the "DECODE" button found on the page but to no avail. Here is my latest effort.
use strict; use WWW::Mechanize::Firefox; my $url = ""; my $agent = WWW::Mechanize::Firefox->new( activate => 1, autoclose => 0, ); my $sn = "1D7HU18D14J230995"; $agent->get($url); if ( $agent->success() ) { sleep(2); print "Retrieved $url\n"; $agent->form_name('Form'); $agent->field( 'dnn$ctr373$VINBox$tbVIN' => $sn ); sleep(2); $agent->submit_form( form => $agent->current_form()); }
Any hints would be appreciated.

Best regards!

Update: Corion's suggestion (click instead of submit_form) does the trick.

Also good references suggested by Anonymous to learn on CSS selectors for those, like me, not that familiar with these ways.

Thanks to all.

Comment on Elusive button WWW::Mechanize::Firefox
Download Code
Replies are listed 'Best First'.
Re: Elusive button WWW::Mechanize::Firefox
by Corion (Pope) on Aug 11, 2012 at 06:48 UTC

    One approach could be to click the button instead of submitting the form:

    $agent->click({ selector => '#dnn_ctr373_VINBox_btnVIN' });
      Thanks Corion, that did it just fine.

      For my own info, where in the doc could I have found out about the hash key to add before the button id/name? Or is this some web convention not specific to the module?

      Thanks again for the boost!

        The syntax of CSS selectors is defined in some CSS standard, which WWW::Mechanize::Firefox uses. The documentation only mentions CSS selectors, but not their syntax or their definition. I guess that googling for them will turn up the relevant RFC or standard. Personally, I've mostly (re)used what others use and am not aware off-hand of a link to a standard.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://986845]
Approved by bulk88
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-11-25 00:59 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (666 votes), past polls