Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select a Radio Button?

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)>>
like image 623
Dimitris Leventeas Avatar asked Sep 26 '10 14:09

Dimitris Leventeas


People also ask

How can I get radio button selected?

To set a radio button to checked/unchecked, select the element and set its checked property to true or false , e.g. myRadio. checked = true . When set to true , the radio button becomes checked and all other radio buttons with the same name attribute become unchecked. Here is the HTML for the examples in this article.

How do I select a radio button on my keyboard?

When focus moves to the group in which a radio button is selected, pressing Tab and Shift+Tab keys move focus to the radio button that is checked. Up Arrow and Down Arrow keys move focus and selection. Up Arrow key press moves focus and selection forward through the radio buttons in the group.

How can I select a single radio button?

To create each radio button option, create a RadioButton in your layout. However, because radio buttons are mutually exclusive, you must group them together inside a RadioGroup . By grouping them together, the system ensures that only one radio button can be selected at a time.


1 Answers

It should be as simple as

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

I prefer the more verbose:

br.form.set_value(['1'],name='prodclass')
like image 106
Mark Avatar answered Nov 10 '22 07:11

Mark