I'm writing some web tests with the Django webtest where I'm trying to set one radio button in a pair of radio buttons to be checked. Naturally, they both have the same name
attribute value.
Using pdb
, and assuming I have a form
variable whose type is webtest.forms.Form
, here's what I see if I type form.html
, i.e. what Webtest has been handed by beautifulsoup (only part of it, but the relevant part).
<input name="is_external" type="radio" value="False"/>
<input name="is_external" type="radio" value="True"/>
Normally to select a specific input element which shares a name with other input elements I'd do something like form.get('is_external', index=1)
which would in this example select the input
whose value is True
.
However, when I do this I'm merely given the error message:
*** IndexError: list index out of range
.
form.get('is_external')
on its own will only give me the first one. I've checked the docs and they are sadly lacking when it comes to radio buttons.
Am I missing something? I've used this method with type="checkbox"
elements before and I've had no problems.