Search code examples
appiumandroid-uiautomator

how to locate an element using UIAutomater when same thing is shared by two element


in the attachment which i shared the camera picture and all photos have same resource-id class and everything then how to click on All photos, because if i am using anything always camera picture is getting clicked

Both the Camera picture and All photos have same element locator then how can we click All pictures, i have explained everything in picture description


Solution

  • Appium interprets page as an XML, so there are no two elements with the same locator. So you can locate by the folder names for example.

    def cameraPicturesLocatorBy = By.xpath("//*[@text='Camera pictures']")

    and

    def allPhotosLocatorBy = By.xpath("//*[@text='All photos']")