How to locate all checkbox items which contains subtext "yes" in Appium?

I have problems to locate only “yes” Items in Appium. So if I have tried:

Xpath: //]/android.view.ViewGroup//[contains(@text, ‘Item’) and not(contains(@text(),‘no’))]**

Xpath: ///android.view.ViewGroup// [contains(@text, ‘Item’) and not(contains(@text,‘no’))]

It seems that not contains does not work in this case.

How could I get this? Using XPath or a regex? I am a bit without ideas on that…

Use better UiSelector with fromParent option

Android: Doc: https://developer.android.com/reference/androidx/test/uiautomator/UiSelector
Appium examples with page object: https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/pagefactory_tests/AndroidPageObjectTest.java

if you like without page object it will be something like:

List<MobileElement> elementList = driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().resourceIdMatches(\".*item\").fromParent(new UiSelector().text(\"yes\"))"));

unfortunately we do not see on screenshot path to ‘yes’. if it in general visible or not - this is a question.

do not replace " -> ’ !
it should not give any error: either nothing found or found. any error = something wrong with your code.
add your code lines…

are you with Java? write your code…

and start from simple things:

List<MobileElement> elementList = driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().resourceIdMatches(\".*subsection.*\")"));
System.out.println("elementList side: " + elementList.size());

works above code?

Thanks for support, I just found the element by Xpath, am using Python.