I have this HTML code:
<td><input name="selFundDetails" type="radio"></td>
I am trying to set the radio button using the keyword "Select Radio Button" to set the value to "Yes".
I tried using:
Select Radio Button selFundDetails Yes
I am getting error as:
20160316 16:17:38.216 : INFO : Verifying element 'selFundDetails' is visible.
20160316 16:17:38.362 : INFO : Selecting 'true' from radio button 'selFundDetails'.
20160316 16:17:38.667 : FAIL : ValueError: Element locator 'xpath=//input[@type='radio' and @name='selFundDetails' and (@value='true' or @id='true')]' did not match any elements.
Your radio button doesn't have a value
or id
, which is required for Select Radio Button
to know which radio button you want it to click. Your name=selFundDetails
only tells the keyword which group you are targeting.
From the Selenium2LibraryDocs:
Select Radio Button
Sets selection of radio button group identified by group_name to value.
The radio button to be selected is located by two arguments:
group_name
is used as the name of the radio input,
value
is used for the value attribute or for the id attribute
The XPath used to locate the correct radio button then looks like this: //input[@type='radio' and @name='group_name' and (@value='value' or @id='value')]
Examples:
Select Radio Button size XL # Matches HTML like <input type="radio" name="size" value="XL">XL</input>
Select Radio Button size sizeXL # Matches HTML like <input type="radio" name="size" value="XL" id="sizeXL">XL</input>
If you control the html, then you can add a value="Yes"
attribute to your radio button and your keyword will work.
If you do not control the html, god help you. But you should be able to click it with a pure Click Element
(by xpath).
select radio button does not work sometimes, if the requirement is to select a radio button, then "click element " will work.