Search code examples
perlwww-mechanize

WWW:Mechanize setvisible


Setting a radio button in the current form is simple:

$clone->set_visible([radio => '1']);

With an unknown number of radio buttons (probably 10 to 20) a loop should work:

while(1) {last if (!$clone->set_visible([radio => '1']));};

However, though setvisible always returns 1. My guess is it only returns 0 when nothing is set at all. But if even one field is set, it can get "re-set".

How do i stop after all radios are set? Or do i need to determine how many there are first?


Solution

  • You can find all inputs you need first:

    my @radio_inputs = $mech->find_all_inputs(
        type       => 'radio',
    );