I’m using WWW::Mechanize for testing my CGI.
I’m having trouble with the $mech->tick
Here’s my code :
ok($mech->form_name('cdr_format'),"getting form cdr_format");
print "pAllFields = " . $mech->value('pAllFields') . "\n";
219-> ok($mech->tick('pAllFields',1), 'Setting checkbox to native CDR format');
220-> ok($mech->tick('pAllFields’,0), 'Setting checkbox to native CDR format’);
Here’s a snippet of the html :
<div id='myForm'>
<form name='cdr_format' method='POST' action='file_admin.cgi'>
<input type='hidden' name='rm' value='process_cdr_format'>
<input type='hidden' name='CGISESSID'
value='ec4c3463d5a7f9d04d2924968413f240'>
<input type='hidden' name='cdr_format' value='1'>
<table border='0' cellpadding='3' cellspacing='0' width='100%'>
<tr>
<td class='fieldLabel' width='60%'>
We would like the files in native CDR format:
</td>
<td class='field'>
<input type='checkbox' class='checkbox' name='pAllFields' value='1'>
</td>
</tr>
When I execute I get this :
ok 40 - getting form cdr_format
Use of uninitialized value in concatenation (.) or string at ./test_cportal.pl
line 218.
pAllFields =
not ok 41 - Setting checkbox to native CDR format
# Failed test 'Setting checkbox to native CDR format'
# at ./test_cportal.pl line 219.
not ok 42 - Setting checkbox to native CDR format
# Failed test 'Setting checkbox to native CDR format'
# at ./test_cportal.pl line 220.
Here’s the documentation from WWW::Mechanize
$mech->tick( $name, $value [, $set] )
"Ticks" the first checkbox that has both the name and value associated with it
on the current form. Dies if there is no named check box for that value.
Passing in a false value as the third optional argument will cause the checkbox
to be unticked.