Straider
Straider

Reputation: 13

How can set accessibility identifier in attributedPlaceholder

I have the given piece of code

textField.attributedPlaceholder = NSAttributedString(string: Strings.test,
                                                             attributes: [NSAttributedString.Key.foregroundColor: ColorTheme.test])

How I can set an accessibility identifier in attributedPlaceholder so that I can later use the containing string in the UITest?

Upvotes: 0

Views: 466

Answers (1)

Gopito
Gopito

Reputation: 61

You need to give accessibility identifier to your textfield. Then you can get the placeholder text via property.

let textField = XCUIApplication().textFields["textFieldIdentifier"]
let placeholderText = textField.placeholderValue

Upvotes: 1

Related Questions