Summary
Calling click_button( input => $input ) with an HTML::Form::Input object does
not actually press that submit button. The button's own name/value pair (e.g.
submit=Go) is missing from the resulting request, even though the correct
input object was passed in.
This is currently documented as a TODO test in t/local/click_button.t
(the "click by object reference" subtest), where it produces:
ok 1 - 'Found the submit button' isa 'HTML::Form::Input'
ok 2 - Named the right thing, too
not ok 4 - Correct button was pressed # TODO Calling ->click() on an object doesn't seem to use the submit button.
# at t/local/click_button.t line 126.
# 'http://[::1]:PORT/formsubmit?session=1&query=(empty)&cat=cat_foo&cat=cat_bar&upload='
# doesn't match '(?^:submit=Go)'
Note the request URI omits submit=Go, so the submit input that was explicitly
passed never contributes its value.
Reproduction
From t/local/click_button.t:
my $clicky_button = $form->find_input( undef, 'submit' ); # isa HTML::Form::Input
my $res = $mech->click_button( input => $clicky_button );
# Expected the request to include submit=Go; it does not.
Relevant code
lib/WWW/Mechanize.pm, in click_button():
elsif ( $args{input} ) {
$request = $args{input}->click( $form, $args{x}, $args{y} );
}
By contrast, the name/number/id branches resolve an input via the form and
click it, and those paths transmit the button's name/value correctly. The
input => branch clicks the passed object directly but the button's name/value
does not end up in the request.
Expected behaviour
click_button( input => $submit_input ) should press that specific submit
button and include its name=value pair in the request, matching the behaviour
of the other selector forms.
Notes
The behaviour is already captured by a failing TODO test in the
"click by object reference" subtest of t/local/click_button.t; that test can be
un-TODO'd once this is fixed.
Summary
Calling
click_button( input => $input )with anHTML::Form::Inputobject doesnot actually press that submit button. The button's own name/value pair (e.g.
submit=Go) is missing from the resulting request, even though the correctinput object was passed in.
This is currently documented as a
TODOtest int/local/click_button.t(the "click by object reference" subtest), where it produces:
Note the request URI omits
submit=Go, so the submit input that was explicitlypassed never contributes its value.
Reproduction
From
t/local/click_button.t:Relevant code
lib/WWW/Mechanize.pm, inclick_button():By contrast, the
name/number/idbranches resolve an input via the form andclick it, and those paths transmit the button's name/value correctly. The
input =>branch clicks the passed object directly but the button's name/valuedoes not end up in the request.
Expected behaviour
click_button( input => $submit_input )should press that specific submitbutton and include its
name=valuepair in the request, matching the behaviourof the other selector forms.
Notes
The behaviour is already captured by a failing
TODOtest in the"click by object reference" subtest of
t/local/click_button.t; that test can beun-TODO'd once this is fixed.