Appium appium 中 find_elements_by_android_uiautomator 怎么用来定位

tianwei · 2014年06月20日 · 最后由 恒温 回复于 2014年06月20日 · 1477 次阅读

如题,小弟最近在研究 appium,现在遇到一个比较难定位的元素,看了下 api,发现有个 find_elements_by_android_uiautomator 和 find_element_by_accessibility_id 方法是 appium 中独有的方法。在 selenium 里面没有。
但是这 2 个方法都不会用,求大神代码指点。

共收到 5 条回复 时间 点赞
def find_elements_by_android_uiautomator(self, uia_string):
      """Finds elements by uiautomator in Android.

      :Args:
       - uia_string - The element name in the Android UIAutomator library

      :Usage:
          driver.find_elements_by_android_uiautomator('.elements()[1].cells()[2]')
      """
      return self.find_elements(by=By.ANDROID_UIAUTOMATOR, value=uia_string)

  def find_element_by_accessibility_id(self, id):
      """Finds an element by accessibility id.

      :Args:
       - id - a string corresponding to a recursive element search using the
       Id/Name that the native Accessibility options utilize

      :Usage:
          driver.find_element_by_accessibility_id()
      """
      return self.find_element(by=By.ACCESSIBILITY_ID, value=id)

Allows for elements to be found using the "Accessibility ID". The methods take a
string representing the accessibility id or label attached to a given element, e.g., for iOS the accessibility identifier and for Android the content-description. Adds the methods
driver.find_element_by_accessibility_id and find_elements_by_accessibility_id.

没有头像,晚上删帖。

不要啊,怎么上传头像

我看不懂 api 上描述,这个描述我看的,有实例代码吗?

这两种方法我也没有用过,那个 accessibility 我查了半天也没弄明白指的具体是什么, 不过你这个直接用 name,或者 class name 之类的定位不到么?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册