swift - 如何在 attributesPlaceholder 中设置可访问性标识符
问题描述
我有给定的一段代码
textField.attributedPlaceholder = NSAttributedString(string: Strings.test,
attributes: [NSAttributedString.Key.foregroundColor: ColorTheme.test])
如何在AttributePlaceholder 中设置可访问性标识符,以便以后可以在UITest 中使用包含字符串?
解决方案
您需要为您的文本字段提供可访问性标识符。然后您可以通过属性获取占位符文本。
let textField = XCUIApplication().textFields["textFieldIdentifier"]
let placeholderText = textField.placeholderValue
推荐阅读
- android - ViewModelProvider中的androidx.lifecycle.ViewModelStoreOwner不能应用到androidx.lifecycle.LifeCycleOwner
- mysql - 如何解释 mariadb/mysql 中的语法错误 1064
- ssl - 我们如何在物联网架构中使用letsencrypt SSL证书
- node.js - 如何关闭节点 js mssql 中的连接?
- orientdb - 如何在 orientDB 等图形数据库中有约束?
- amazon-web-services - AWS 中的 SSL 证书安装问题
- ios - 带有 let 属性的 private(set) - 'private(set)' 修饰符不能应用于只读属性
- r - 如何根据具有不同元素数量的另一个数据框分配值?
- python-3.x - 如何更新 Dataframe 的行以使它们成为具有列名的字典?
- java - 为什么我在 Java 类型转换中出现错误