【问题标题】:How can set accessibility identifier in attributedPlaceholder如何在 attributesPlaceholder 中设置可访问性标识符
【发布时间】:2021-07-27 13:41:51
【问题描述】:

我有给定的代码

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

我如何在属性Placeholder 中设置可访问性标识符,以便以后可以在 UITest 中使用包含字符串?

【问题讨论】:

    标签: swift xctest


    【解决方案1】:

    您需要为您的文本字段提供可访问性标识符。然后就可以通过属性获取占位符文本了。

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

    【讨论】:

      猜你喜欢
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      • 2013-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多