UI Automator Viewer 报错总结

2018-08-25  本文已影响287人  AsaGuo
  1. 点击 Device ScreenShot Dump 报错
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!

解决方案:

1.1 重新连接手机 → 选择 USB 用途 → 传输文件(MTP)
1.2 提示“是否允许调试” → 允许
1.3 命令提示符 → adb devices → 查看是否有设备:

C:\User\Asa> adb devices
List of devices attached
adb server version (31) doesn't match this client (40); killing...
* daemon started successfully
2956549f7d23    device

1.4 打开UI Automator Viewer

  1. 调用安卓手机chrome报错
    错误:
selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device 2956549f7d23 is not online
  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64)))

解决方案:

  1. 查看手机Chrome版本
  2. 下载对应Chrome 的 Chromedriver版本
    http://chromedriver.storage.googleapis.com/index.html
  3. 将appium下的Chromedriver替换掉,我的路径如下:
# 旧版本:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\

# 新版本
C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win
  1. 可以定位验证码输入框元素,但是点击“获取验证码”后,输入验证码报错
input_auth_code.set_text(vercode)

错误:

# 无法获取元素
selenium.common.exceptions.NoSuchElementException: Message: UiSelector[INSTANCE=0, RESOURCE_ID=com.xike.yipai:id/edt_login2_verifi_code]

# 或者超时
selenium.common.exceptions.TimeoutException: Message: 

解决方案:
获取验证码之前,为验证码输入框设置焦点

    # 设置焦点
    input_auth_code.set_text('')
    # 获取验证码
    vercode = get_vercode()
    # 输入验证码
    input_auth_code.set_text(vercode)
上一篇 下一篇

猜你喜欢

热点阅读