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()

求各位指点指点

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值