iPhone - 自动化测试?
我目前在编写自动化测试时通过可访问性标签来检测元素? 这会导致很多问题。
- 这是检测元素的正确方法吗?
- 如果没有的话有没有更好的方法 检测元素而不使用 可访问性标签?
I am currently detecting elements by their accessibility labels when writing automation testing?
This causes a lot of problems.
- Is this the correct way of detecting elements?
- If not is there a better way to
detect elements without using the
accessibility label?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UI 自动化使用辅助功能标签(如果已设置)来派生每个元素的名称属性。除了明显的好处之外,使用此类名称还可以大大简化测试脚本的开发和维护。
name 属性是这些元素的四个属性之一,在测试脚本中非常有用。
标签
控制,例如,a 中的文本
文本字段
当前包含的元素
元素,例如,a 中的单元格
表视图
包含当前元素
仪器用户指南
UI Automation uses the accessibility label (if it’s set) to derive a name property for each element. Aside from the obvious benefits, using such names can greatly simplify development and maintenance of your test scripts.
The name property is one of four properties of these elements that can be very useful in your test scripts.
label
control, for example, the text in a
text field
elements contained within the current
element, for example, the cells in a
table view
contains the current element
Instruments User Guide
不明白你说的“这会导致很多问题”是什么意思。通过自动化仪器中的可访问性属性来访问元素非常容易。
当然,您也可以按屏幕上的顺序访问元素。例如:
将引用屏幕上的第四个按钮(它们从 0 开始编号)标签。但如果您决定在应用程序的下一版本中重新排列屏幕上的元素,此方法可能会破坏您的测试,因此通过辅助功能标签访问它们更安全。
此外,辅助功能元素使您的应用程序对于依赖 VoiceOver 使用应用程序界面的人(残障人士)来说更容易访问,因此在进行界面测试时使用辅助功能属性会迫使您为应用程序构建更好的辅助功能。
Don't understand what you mean by "This causes a lot of problems.". Accessing elements by their accessibility properties in Automation Instrument is quite easy.
Of course you can access elements also by their order on the screen. For example:
will refer to 4th button (they are numbered from 0) label on your screen. But in case you will decide to rearrange elements on your screen in next version of the app this method can broke your tests, therefore accessing them by accessibility label is more safe.
In addition accessibility elements makes your app more accessible for people (with disabilities) who will rely on VoiceOver for using app interface- so using accessibility properties in making interface tests force you to build better accessibility for your app.