“message“:“java.lang.IllegalArgumentException: Namespace with prefix ‘xx‘ has not been declared

运行操作
运行python 脚本
错误日志

[HTTP] --> POST /wd/hub/session/0fc42238-dd32-4c85-b4d7-c08920ef4cc3/element

[HTTP] {"using":"xpath","value":"com.xueqiu.android:id/action_close"}

[debug] [W3C (0fc42238)] Calling AppiumDriver.findElement() with args: **["xpath","com.xueqiu.android:id/action_close","0fc42238-dd32-4c85-b4d7-c08920ef4cc3"]**

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

[debug] [BaseDriver] Waiting up to 10000 ms for condition
[debug] [WD Proxy] Matched '/element' to command name 'findElement'

[debug] [WD Proxy] Proxying [POST /element] to [POST http://localhost:8209/wd/hub/session/c8198f76-0603-4a26-8183-853c5064d3a5/element] with body: {"strategy":"xpath","selector":"com.xueqiu.android:id/action_close","context":"","multiple":false}

[WD Proxy] Got an unexpected response with status 500: {"sessionId":"c8198f76-0603-4a26-8183-853c5064d3a5","value":{"error":"unknown error","message":"java.lang.IllegalArgumentException: Namespace with prefix 'com.xueqiu.android' has not been declared.","stacktrace":"io.appium.uiautomator2.common.exceptions.UiAutomator2Exception: java.lang.IllegalArgumentException: Namespace with prefix 'com.xueqiu.android' has not been declared.\n\tat io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.findNodes(AccessibilityNodeInfoDumper.java:237)\n\tat io.appium.uiautomator2.utils.ElementLocationHelpers.getXPathNodeMatch(ElementLocationHelpers.java:86)\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:100)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(Appiu...

[debug] [W3C] Matched W3C error code 'unknown error' to UnknownError

问题分析

关键错误日志提示:不合法的参数异常,前缀是’com.xueqiu.android 的命名空间未定义,见下文;
这句话其实说的selector 中的com.xueqiu.android 前缀未定义;xpath表达式的前缀一般都是”//*“ 发现xpath表达式中写的是id 的表达式
{“strategy”:“xpath”,“selector”:“com.xueqiu.android:id/action_close”,“context”:"",“multiple”:false}

{"sessionId":"c8198f76-0603-4a26-8183-853c5064d3a5","value":{"error":"unknown error","message":"java.lang.IllegalArgumentException: Namespace with prefix 'com.xueqiu.android' has not been declared."

解决方案

把xpath 修改为id

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值