This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Find xpath that doesn't have specific child

How can I select objects, that don't have a specified child? For example, I need to find objects, that don't have resource-id "btn-add-remove", in example below is container[2].

MobileObject[@resource-id='container']

MobileObject[@resource-id='cardView']

MobileObject[@resource-id='btn-add-remove']

MobileObject[@resource-id='tv_menu_title']

MobileObject[@resource-id='container'][2]

MobileObject[@resource-id='cardView']

MobileObject[@resource-id='btn-add-remove']

MobileObject[@resource-id='tv_menu_title']

The Xpath that I have tried are

- MobileObject[@resource-id='cardView or @resource-id='tv_menu_title' and not @resource-id!='btn-add-remove']/ancestor::MobileObject[@resource-id='container']

- MobileObject[@resource-id='container']//MobileObject[@resource-id='cardView or @resource-id='tv_menu_title' and not @resource-id!='btn-add-remove']

both resulted in container1

Parents Reply Children
No Data