Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Mechanize select with "id" or "class" other than "name".

by Anonymous Monk
on Nov 12, 2012 at 09:33 UTC ( [id://1003393]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks, have a small Issue with mechanize. My target source code didn't have a "name" field associated with it. but its having "id" and "class".

Target source code look like this

<select id="keyword-country-option" class="dropdown"> <option value="Choose Location">Choose Region< +/option> <option value="AMEA">Asia, Middle East &amp; A +frica</option> <option value="Canada">Canada</option> <option value="Europe">Europe</option> <option value="Latin America">Latin America</o +ption> <option value="United States">United States</o +ption> </select>

I wish to use $mech->select($name, $value); Is there any way to achieve this..? Thank you.

Replies are listed 'Best First'.
Re: Mechanize select with "id" or "class" other than "name".
by Corion (Patriarch) on Nov 12, 2012 at 09:39 UTC

    ->select uses HTML::Form->find_input, so you should be able to specify an id by using a # prefix:

    $mech->select('#keyword-country-option', 'Canada');

      Thank you...

Log In?
Username:
Password:

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

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

    No recent polls found