How to validate radio button is checked or not using Appium

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.

https://groups.google.com/forum/#!topic/appium-discuss/h_eBRM-ZbdU

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…

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" />