How to select a Radio Button?

耗尽温柔 提交于 2020-01-02 01:53:08

问题


I am using mechanize and I am trying to select a button from a radio button list. This list has 5 items. How can I select the first item? Docs didn't help me.

>>> br.form
<ClientForm.HTMLForm instance at 0x9ac0d4c>
>>> print(br.form)
<form1 POST http://www.example.com application/x-www-form-urlencoded
<HiddenControl(DD=17010200) (readonly)>
<RadioControl(prodclass=[1, 2, 3, 4, 5])>
<SubmitControl(submit=text) (readonly)>>

回答1:


It should be as simple as

br.form['prodclass'] = ['1']

I prefer the more verbose:

br.form.set_value(['1'],name='prodclass')


来源:https://stackoverflow.com/questions/3798138/how-to-select-a-radio-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!