How to click on an iOS MobileElement (button) which is dynamically changing using XPath



  • Below is the XPath-

    //XCUIElementTypeButton[@name="8/13"]

    The numeric value in the above XPath changes and is not static. There are more then 10 buttons on the screen, I want to click on the first one.

    Text1                 btn1   //let’s say btn1 contains 8/13
    
    Text2                 btn2   //let’s say btn1 contains 4/8
    

    Can anyone help me to achieve this task?



  • I think in XPath you are using the name or value may be keep on changing, so can go for the concept of following sibling for getting the proper XPath.

    Example:

     //XCUIElementTypeButton[@name='testing']/../following-sibling::XCUIElementTypeStaticText
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2