Search code examples
javaiosxpathappium

Xpath writing for one element which doesn't have any unique id


Currently in my application accessibility id is not implemented for elements and I am facing challenges in locating the xpath. Using properties how can I write the xpath? I am using appium studio on windows to automate an iOS app.

I written some xpath,which is not working.

       (//*[@class='UIATabBar']/*[@class='UIAButton'])[2] 

for 2nd image the xpath is

        //*[@class='UIAView' and ./*[@id='2Test WebApp']]

If I want to iterate using for loop, not getting xpath,where changing the value I can iterate in the list.

This xpath is suggested by appium studio itself,but it is not working.and not able to write unique xpath. Attached the image as well to get clear idea.enter image description here

enter image description here


Solution

  • try this. you are trying to get the 2nd button.

    (//*[@class='UIATabBar']/*[@class='UIAButton'][2])
    

    For the 2nd one.

    //*[@class='UIAView'][*[@id='2Test WebApp']]