问题描述
我在真实设备中使用 Appium/TestNG 来自动化应用程序,但某些元素在其他语言中具有 [@text='string'].在其他语言上使用相同代码而不是为每种语言创建一个代码的最佳解决方案是什么?
i´m using Appium/TestNG in real devices to automate an application, but some elements have the [@text='string'] with other languages. what´s the best solution to use the same code on other languages instead of creating one code for each language ?
推荐答案
最佳实践是永远不要使用像 //*[@text='string']
Best practice is to never use XPath locators like //*[@text='string']
对于 Android 应用程序使用 resource-id
或 uiautomator
定位器策略
For Android apps use resource-id
or uiautomator
locator strategies
对于 iOS 应用程序 accessibility-id
或 ios 类链
定位器策略
For iOS apps accessibility-id
or ios class chain
locator strategies
这将有助于保持您的测试稳定且相当快
It will help to keep your tests stable and reasonably fast
这篇关于Appium TestNG - 如何识别其他语言中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!