Robert Poor
2011-Sep-08 17:20 UTC
[Mechanize-users] setting a form field creates duplicate fields?
I receive a form, I set some fields, I post the form. ?It all seems to
work, along these lines:
form[''__EVENTTARGET''] =
''objTimePeriods$rlPeriod$1''
form[''__EVENTARGUMENT''] = ''''
? ? form[''objTimePeriods$rlPeriod''] = 2
? ? agent.submit(form)
But when I look at what''s going out over the wire (thanks to the
delightful www.charlesproxy.com), I see the following being posted:
objTimePeriods$rlPeriod: 2
__EVENTTARGET: objTimePeriods$rlPeriod$1
__EVENTARGUMENT:
objTimePeriods$rlPeriod: 1
Notice that the ''objTimePeriods$rlPeriod'' field appears twice
-- the
''1'' was the previous value of the form before I set it to
''2''. I''ve
quadruple-checked the spelling and punctuation (even in the raw
transmitted byte stream), and they really do have the same field
names.
My code seems to work, but this may be just luck. Am I doing
something wrong? Do I need to check for the presence of a form field
before I set it?