Locator with date in it - dynamic

Hi folks,

how would you handle the below locator:
**/XCUIElementTypeStaticText[label == "Mar 31, 1999"]
//XCUIElementTypeStaticText[@name=“Mar 31, 1999”] - “Mar 31, 1999part of locator is dynamic and can change anytime to another date.

I was thinking as below but not too sure:
//XCUIElementTypeStaticText[matches(@label, “^[A-Z][a-z]{2} \d{2}, \d{4}$”)]

Just my opinion, but while a regular expression is nice and should work, it would be far better to ask the developers to add an accessibility id to that element.


start from third post and further -> Dynamic Locator in iOS App