Appium/Android Help getting find element to work

@Wai_Chu

Hello again!

I am having another issue that I cant seem to solve. For some reason it is hit and miss on finding my element:
sunshine = self.driver.find_element_by_android_uiautomator(‘new UiSelector().description(“1 Sunshine”)’)
vs
sunshine = self.driver.find_element_by_android_uiautomator
(‘new UiSelector().className(“android.view.View”).description(“1 Sunshine”)’)

Some times it finds it under the 1st option and other times it doesn’t. How do you best write something in python to check for both and click that one that actually appears so the test will run consistently?

Thank you,

It is related to xpath axes, write your xpath by using or, it will check first xpath if found then will work otherwise it will check the second one.
Try to search out how to use and/or in xpath for python, I have worked on only in java. Thanks

@Steven_Rutherford
post a screen grab of the inspector with the element.