I think in XPath you are using the name or value which may be keepdynamic (keeps on changing). So, soyou can go for the concept of following siblingfollowing sibling for getting the proper XPath.
Example:
//XCUIElementTypeButton[@name='testing']/../following-sibling::XCUIElementTypeStaticText