I have a button with dynamic title text, set up as follows:
button.label = @"Chosen Date Button";
[button setTitle:stringOfDateChosenByUser
forState:UIControlStateNormal];
In my UI test, I want to verify this title text. I managed to access the button using:
XCUIElement *button = app.buttons[@"Chosen Date Button"];
But I can't seem to access the title property of the button (contents of stringOfDateChosenByUser) in any of the following fields I've tried. I've included the respective outputs in comments:
NSLog(@"strings to examine: %@ %@ %@ %@ %@ %@",
(NSString *)button.value, //<empty string>
button.title, //<empty string>
button.label, //@"Chosen Date Button"
button.identifier, //<empty string>
button.accessibilityLabel, //null
button.accessibilityValue); //null
Since the title is visible on screen, I'm guessing that there should be a way to access it. Is there?