我是靠谱客的博主 单薄大炮,最近开发中收集的这篇文章主要介绍android id标签,appium1.7.1,android7.0+ 上,元素 ID 识别不了,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

appium 版本 1.7.1,python 环境,使用的 appiumlibrary 库,版本如下:

6d2284ee4708a02e2836ccfda479fac9.png

页面上的元素 “关闭易信首页提示” 在 automator viewer 里面能找到,且在 android5.0 的手机上控件能正常识别

3d7b38cf61f461045e3ee23785435c6d.png

但是在 android7.0、android8.0 的手机上,不管使用 ID 还是 name 定位的方式都找不到。appium 的 log 如下:

[info] [HTTP]

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}[info] [HTTP] --> POST /wd/hub/session/3623631a-ebf6-4fe2-b4fe-661a9f263b45/elements {"using":"id","sessionId":"3623631a-ebf6-4fe2-b4fe-661a9f263b45","value":"im.yixin:id/btn_agenda_un_track"}

[debug] [MJSONWP] Calling AppiumDriver.findElements() with args: ["id","im.yixin:id/btn_agenda_un_track","3623631a-ebf6-4fe2-b4fe-661a9f263b45"]

[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator, name

[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator, name

[debug] [BaseDriver] Waiting up to 0 ms for condition

[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"im.yixin:id/btn_agenda_un_track","context":"","multiple":true}}

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"im.yixin:id/btn_agenda_un_track","context":"","multiple":true}}

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'im.yixin:id/btn_agenda_un_track' using 'ID' with the contextId: '' multiple: true

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=im.yixin:id/btn_agenda_un_track]

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[RESOURCE_ID=im.yixin:id/btn_agenda_un_track]

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0)

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=im.yixin:id/btn_agenda_un_track][debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'im.yixin:id/btn_agenda_un_track' using 'ID' with the contextId: '' multiple: true

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=im.yixin:id/btn_agenda_un_track]

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[RESOURCE_ID=im.yixin:id/btn_agenda_un_track]

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0)

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=im.yixin:id/btn_agenda_un_track][debug] [AndroidBootstrap] Received command result from bootstrap

[debug] [MJSONWP] Responding to client with driver.findElements() result: []

[info] [HTTP]

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[]}

这个页面的其他元素,在 android7.0、8.0 上能正常识别,只有这个元素,

看了下 appiumlibrary 中 click_element 这个方法,写的是:

def click_element(self, locator):

"""Click element identified by `locator`.

Key attributes for arbitrary elements are `index` and `name`. See

`introduction` for details about locating elements.

"""

self._info("Clicking element '%s'." % locator)

self._element_find(locator, True, True).click()

求各位指点指点

最后

以上就是单薄大炮为你收集整理的android id标签,appium1.7.1,android7.0+ 上,元素 ID 识别不了的全部内容,希望文章能够帮你解决android id标签,appium1.7.1,android7.0+ 上,元素 ID 识别不了所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部