How to check the checkBox status for IOSElement?

I used element.isSelected() method but I got WebDriverException.

Below is my Environment:
Framework: XCUITest
Xcode: 8.3.3
Appium : v1.7.2-beta2
iPad iOS version: 10.3.3
io.appium.java-client api version: 5.0.4

Below is the appium logs for the same.

[HTTP] --> GET /wd/hub/session/c3a390bd-3c36-4726-9709-2c43bdc945d8/element/022B7019-D952-4144-81B2-E6655AAFBA5A/selected {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [XCUITest] Executing command ‘proxyReqRes’
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/c3a390bd-3c36-4726-9709-2c43bdc945d8/element/022B7019-D952-4144-81B2-E6655AAFBA5A/selected] to [GET http://localhost:8100/session/AD183A58-4B2F-4273-80DB-B885E8A679E3/element/022B7019-D952-4144-81B2-E6655AAFBA5A/selected] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: “{\n “value” : “Unhandled endpoint: \/session\/AD183A58-4B2F-4273-80DB-B885E8A679E3\/element\/022B7019-D952-4144-81B2-E6655AAFBA5A\/selected – http:\/\/localhost:8100\/ with parameters {\n wildcards = (\n \“session\/AD183A58-4B2F-4273-80DB-B885E8A679E3\/element\/022B7019-D952-4144-81B2-E6655AAFBA5A\/selected\”\n );\n}”,\n “sessionId” : “AD183A58-4B2F-4273-80DB-B885E8A679E3”,\n “status” : 1\n}”

Hi @ramesh_sriram

You should be able to get the attribute value of the element.

You could do:
boolean checked = driver.findElementByXPath("<XPATH>").getAttribute("value").equals("checked");
values are checked and unchecked

Or you could do
boolean checked = driver.findElementByXPath("<XPATH>").getAttribute("checked").equals("checked");

It really depends on the attribute this element has.

Hi @Nivi_Mor
I got the below result while getting the attribute values.

  1. element.getAttribute(“value”) resulting “null” and element.getAttribute(“checked”) resulting “WebDriverException”.

Please find the element details in Inspection mode(screenshot attached) and it looks it is not checkBox element and it doesn’t contains any checked attribute.

@ramesh_sriram

Is this screenshot taken from Appium inspector?

I see that the element has very small set of attributes and I’m not sure why that is.

Try to get the page source while in this view. Check some of the checkbox manually and then try:
driver.getPageSource();

Maybe there you will be able to find the attributes you are looking for.

Hi @Nivi_Mor,

Yes… That is appium inspector screenshot.

Inspector showing the checkbox element type as XCUIElementTypeOther also driver.getPageSource(); listing the attributes showing in the appium Inspector.

So please help me to identify the checkbox status.

Thanks,
Ramesh Sriram

Hi @ramesh_sriram

In that case, I’m not sure how you will be able to check the status of the checkbox.

Usually, for checkboxes, radio buttons, switches etc., there is an attributed checked, or value that indicates their status.

I see in the screenshot that the element that is selected is the last one in a hierarchy of 4 elements. What sort of attributes do you get when you select the parent elements of the element that is selected in the screenshot?

Appium inspector resulting same attributes for those 4 parent items as well. It seems the problem with the checkbox element type: XCUIElementTypeOther instead of the actual element type something like XCUICheckBox

@ramesh_sriram So, what’s the final decision, Ramesh? We are also trying to automate React Native application using appium and we are facing the same issue. Did you find any workaround?

please if you find the solution , advise me , i face this issue now