Hi All
Please suggest me webdriver method/code to validate radio button ?
I have verified using this functions and unable to validate it
isDisplayed()/isSelected()/isEnabled
Please suggest me code validate to radio button is checked ?
Thanks in advance
Shashi JB
check using ui Automator if you get a locator for checked Radio box, and then validate it’s presence.
Degard
March 16, 2016, 6:42am
4
Pay attention on value attribute.
It usually 1 when it is checked and 0 when unchecked.
In this case you can use code:
webElement.getAttribute(“value”).equals(“1”);
Best way I would suggest is to take that element into list and compare with list.size() >0
Thanks a lot for the info…
ammar
April 6, 2022, 6:35am
7
There is a property named “checked” (see below example) which you can get using element.get_attribute(‘checked’) and then compare. if it is true then it is ON or else OFF. hope this helps.
<android.widget.CheckBox index="0" package="com.android.settings" class="android.widget.CheckBox" text="" resource-id="android:id/checkbox" checkable="true" **checked="false"** clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[866,435][1000,587]" displayed="true" />