I'm trying to use mechanize to select a form
browser.select_form('frmChangeLanguage')
.. got that.
But I'm struggling with changing a drop down box within the form and then submitting the form with the new value. The control looks like this:
<table>
<tr>
<td>
<select id="controlID" class="select" name="selectLang">
<option value='4' selected>en</option>
<option value='1' >fr</option>
<option value='2' >hk</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" name="button" id="button" value="Submit"/></td>
</tr>
</table>
I'm currently doing:
control = browser.form.controls[0]
control._value = 1
browser.submit(name='button')
but this doesn't seem to be working. Any ideas? I'm using Python 2.7 with Mechanize installed on Windows.
According to the docs, the following should work:
form["selectLang"] = ["1"]
mechanize.urlopen(form.click())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With