Error obtaining Ul hierarchy Reason: Error while obtaining Ul hierarchy XML file

简介: Error obtaining Ul hierarchy Reason: Error while obtaining Ul hierarchy XML file

一、前置说明


在运行完Appium测试脚本之后,再次使用uiautomatorviewer定位页面元素时,经常会报错:

Error  obtaining  Ul  hierarchy
Reason:
Error  while  obtaining  Ul  hierarchy  XML  file:
com.android.ddmlib.SyncException:  Remote  object  doesn't  exist!



二、解决办法


出现该问题的原因是: Appium Session未结束,当前APP仍处于测试脚本控制之中,所以使用uiautomatorviewer定位页面时,会报"设备不存在"的错误。


方案一:使用quit()方法关闭Appium会话

driver.quit()


方案二:等待一段时间,让Android设备自动断开会话

等待设备自动断开当前会话,断开的标志是:自动退出测试脚本操作的页面,回到首页


三、其他说明


出现该问题,可能还有其他未知的原因,如果上面两种方法仍不能解决问题,那就重启设备、重启uiautomatorviewer。

请相信:有时候,重启可以解决大部分问题,哈哈


请参考 一键重启appium环境,一键启动过程如下:

  1. 启动模拟器
  2. 开启Android设备远程调试,并连接设备
  3. 启动uiautomatorviewer,用于定位元素
  4. 启动Appium Server,用于自动化移动应用程序的测试
目录
相关文章
|
3月前
|
Docker 容器
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
|
6月前
|
存储 缓存 自然语言处理
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
49 1
|
7月前
|
XML Android开发 数据格式
Error obtaining Ul hierarchy Reason_ Error while obtaining Ul hierarchy XML file
Error obtaining Ul hierarchy Reason_ Error while obtaining Ul hierarchy XML file
79 0
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
成功解决:ERROR StatusLogger No log4j2 configuration file found.
成功解决:ERROR StatusLogger No log4j2 configuration file found.
|
前端开发 数据库
Failed to load response dataNo data found for resource with given identifier
Failed to load response dataNo data found for resource with given identifier
1631 0
|
Unix Linux 异构计算
成功解决 ERROR: An error occurred while performing the step: “Building kernel modules“. See /var/log/nv
成功解决 ERROR: An error occurred while performing the step: “Building kernel modules“. See /var/log/nv
成功解决 ERROR: An error occurred while performing the step: “Building kernel modules“. See  /var/log/nv
Dx unsupported class file version 52.0 Conversion to Dalvik format failed with error 1
Dx unsupported class file version 52.0 Conversion to Dalvik format failed with error 1
151 0
Error starting ApplicationContext. To display the conditions report re-run your application with
Error starting ApplicationContext. To display the conditions report re-run your application with
1032 0
Error starting ApplicationContext. To display the conditions report re-run your application with
​Error -4075: File not found. An error occurred merging module <MODULENAME> for feature <FEATURENAME>.
​Error -4075: File not found. An error occurred merging module <MODULENAME> for feature <FEATURENAME>.
123 0
​Error -4075: File not found. An error occurred merging module <MODULENAME> for feature <FEATURENAME>.