user3724559
user3724559

Reputation: 239

XCTest Objective C Xcode8.1 how to extract label/value/name of any button or navigator bar

Can anyone tell me how to extract label/value/name of any button or navigator bar

code I have tried so far

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].title;
NSLog(@"%@++++++++", Test);

and

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].accessibilityLabel;
NSLog(@"%@++++++++", Test);

and

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].accessibilityValue;
NSLog(@"%@++++++++", Test);

Output remains null for all the 3 above

Upvotes: 0

Views: 191

Answers (2)

Munahil
Munahil

Reputation: 2419

You will have to use label. For your case replace this as :

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].label;

Upvotes: 1

Oletha
Oletha

Reputation: 7659

Use label to access the value of a static text element.

NSString *test = app.navigationBars[@"Test"].staticTexts[@"Test"].label;
NSLog(@"%@++++++++", test);

https://developer.apple.com/reference/xctest/xcuielementattributes/1500692-label

Upvotes: 1

Related Questions