How to handle multiple radiobutton | Selenium Forum
M
Mustapha Rhouate Posted on 06/03/2020

Hi
I was wondering if anyone can make my classe better 

I am trying to check if first radiobutton is checked  or not if itis check the nextone if not check the radiobutton than check the next one

public class EventDetailChildNameSettingsStepDefs {

    @And("event_details I Enable children settings checkbox (on|off|ON|OFF)$")
    public void event_detailsEnableChildrenSettingsOnOffONOFF(String strCheck1) throws Throwable {
        SimpleAction.runs(() -> {
            TestBase testBase = ObjectDriver.INSTANCE.getTestBase();
            GetAttribute.run(Passkey_Events.PK_Event_ChildrenSettings.chkAskForChildCountYes, "class", "ChildrenSettings");
            if (strCheck1.equalsIgnoreCase("on")) {
                if (!testBase.getGlobalVariable("ChildrenSettings").contains("checked")) {
                    Input.run(Passkey_Events.PK_Event_ChildrenSettings.chkAskForChildCountYes);
                }
            } else if (strCheck1.equalsIgnoreCase("off")) {
                if (testBase.getGlobalVariable("ChildrenSettings").contains("checked")) {
                    Input.run(Passkey_Events.PK_Event_ChildrenSettings.chkAskForChildCountYes);
                }
            }
            Input.run(Passkey_Events.PK_Event_ChildrenSettings.chkAskForChildNameYes);
            Input.run(Passkey_Events.PK_Event_ChildrenSettings.chkMakeNameRequired);
            Input.run(Passkey_Events.PK_Event_ChildrenSettings.chkAskForChildAgeYes);
            Input.run(Passkey_Events.PK_Event_ChildrenSettings.chkMakeAgeRequired);
        });
    }

M
Mustapha Rhouate Replied on 11/03/2020

Hi any help?
I was wondering if I can create datatable that will be set to ON or OFF by the user choice.
Thanks
| list        | values |
| Button1 | ON      |
| Button2 | OFF     |
| Button3 | OFF     |


A
Ashish Thakur Replied on 16/03/2020

You need to traverse each radio button in this case.


M
Mustapha Rhouate Replied on 16/03/2020

You need to traverse each radio button in this case.?

How I do that I am new to java


A
Ashish Thakur Replied on 17/03/2020

Get XPath of each and every radio button and group them accordingly.

Then check the on or off status individually.