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

My problem is the following: I use WWW::Mechanize::FireFox module and when I',m trying tick checkbox - i got message No elements found for Checkbox with name interested\[\] In this site i have checkboxes with the same names but different values. Example:
<input type="checkbox" value="1" name="professionArea[]"> xxxxxxxx <input type="checkbox" value="2" name="professionArea[]"> yyyyyyyy
I think this is a problem with [] in checkbox name. Is anyone able to help me?

Replies are listed 'Best First'.
Re: Perl WWW::Mechanize::Firefox checkbox tick problem
by marto (Cardinal) on Feb 06, 2012 at 09:47 UTC

    So the page in question has checkboxes named professionArea[], and you're looking for interested[]?

Re: Perl WWW::Mechanize::Firefox checkbox tick problem
by Corion (Patriarch) on Feb 06, 2012 at 09:47 UTC

    marto spotted the problem. Your search arguments don't match your HTML. Ignore this reply. Update2: It seems that this reply still might apply:

    It seems that the following lines are the problematic parts in WWW::Mechanize::Firefox::tick:

    ... $name = quotemeta($name); $value = quotemeta($value) if $value; ...

    I think they should only escape double quotes (as that is what is used to produce the XPath expression.

    I recommend using the hashref option to ->tick instead, at least until a fix comes:

    $mech->tick({ xpath => '//input[@type="checkbox" and @name="profession +Area[]"' }, 1);
      Sorry - my bad. In this site there are 2 checkboxes - interested[] and professionArea[]. I can't tick both. And what can I do? And right - there is input names "interested[]" . I wanna tick both but i can't - $mech->field('interested[]' => '1'); didn't work. Have you any sugestion? UPDATE: I use your code : $mech->tick({ xpath => '//input[@type="checkbox" and @name="professionArea[]"' }, 1); and I got message:
      MozRepl::RemoteObject: NS_ERROR_DOM_INVALID_EXPRESSION_ERR: The expres +sion is no t a legal expression. at C:/Perl/site/lib/WWW/Mechanize/Firefox.pm lin +e 2059
      This is it:
      ... my @found = map { $doc->__xpath($_, $n) } $q; # @$query; ...
      EDIT: \o/ YEAH \o/ . Thanks for help. I commented line with quoted and all works fine. Thanks bro!!!!!!!