No Keyword for Radiobutton check

Hi,

I found that there is no Keyword in the Robot framework for verifying if the radio button has been selected or not when the name attribute is not present for the radio button group. I tried the below snippet of code. The robot framework needs a group name but in the HTML, I didn’t find any attribute with “name”.

${is_Selected}= Radio Button Should Be Set To Home Delivery homeDelivery
Run Keyword If ${is_Selected} Log Radio button is not selected ELSE Log Radio button is selected

Output:-
DevTools listening on ws://127.0.0.1:58547/devtools/browser/4e6d0887-95fd-4d4a-8069-963a7fb92aa5
Add a Barbie product to cart from PLP page | FAIL |
No radio button with name ‘Home Delivery’ found.

test PLPOrderAdd :: To add a product to Cart from PLP page | FAIL |
1 test, 0 passed, 1 failed

Is there a way I can use any other attribute instead of a name here or can I use any other syntax to check if the radio button has been selected or not? Can I use the custom library of Python to do this? If yes, how?

Regards,
Subodh

Hi Subodh,

Are you using SeleniumLibrary?

If there is no name attribute on the radio button, then that should be a defect on the app being tested.

Refer to internet standard rfc1866:

8.1.2.4. Radio Button: INPUT TYPE=RADIO
An <INPUT> element with `TYPE=RADIO’ represents a boolean choice. A
set of such elements with the same name represents a 1-of-many choice
field. The NAME and VALUE attributes are required as for check boxes.

You can probably also work around this issue with Element Attribute Value Should Be or Get Element Attribute

Personally I’d leave the test failing and tag it with the defect number, and let the development team fix their code, when they add the group name then update the test.

Dave.

1 Like