windows10下 python+appium自动化测试踩坑记录

目录

 

0x01 踩坑一 failed to start daemon

0x02 踩坑二 SessionNotCreatedException: Message: A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)

0x03 踩坑三 Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user

0x04 踩坑四 r: Failed to start an Appium session, err was: Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "C:\Users\lenovo\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 4f655297 shell "ps 'uiautomator'""

0x06 踩坑六 如何修改chromeoptions

0x07 踩坑七 ImportError: cannot import name 'InvalidArgumentException'

0x08 踩坑八 WebDriverException: Message: The URL '/wd/hub//session' did not map to a valid resource

0x09 踩坑九 KeyError: 'status'

0x10 踩坑十 http://dl-ssl.google.com/android上不去解决方案


0x01 踩坑一 failed to start daemon

原因:daemon使用的端口被其他进程占用

Microsoft Windows [版本 10.0.17134.829]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\lenovo>adb
Android Debug Bridge version 1.0.41
Version 29.0.1-5644136
Installed as C:\Users\lenovo\AppData\Local\Android\android-sdk\platform-tools\adb.exe
C:\Users\lenovo>adb devices
adb server version (31) doesn't match this client (41); killing...
could not read ok from ADB Server
* failed to start daemon
adb.exe: failed to check server version: cannot connect to daemon
C:\Users\lenovo>netstat -aon|findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       5312
  TCP    127.0.0.1:5037         127.0.0.1:55443        ESTABLISHED     5312
  TCP    127.0.0.1:5037         127.0.0.1:55792        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:55837        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:55852        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:55857        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:55873        TIME_WAIT       0
#省略
C:\Users\lenovo>tasklist|findstr "5312"
LdsMobileLink.exe             5312 Console                    1     16,320 K
#在任务管理器中kill掉该进程
C:\Users\lenovo>adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
********        device

参考自:Android ADB Server启动失败

0x02 踩坑二 SessionNotCreatedException: Message: A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)

原因:同时开启了多个

参考自:ruby - Could not find adb Please set the ANDROID_HOME environment variable with the Android SDK root directory path - Stack Overflow

0x03 踩坑三 Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user

原因:

0x04 踩坑四 r: Failed to start an Appium session, err was: Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "C:\Users\lenovo\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s 4f655297 shell "ps 'uiautomator'""

原因:

下载最新的appium-desktop或者参照上图方法

参考自:Appium在Android7.0上无法启动问题 

0x06 踩坑六 如何修改chromeoptions

C:\Users\lenovo>adb shell
oxygen:/ $ dumpsys activity top | grep ACTIVITY
  ACTIVITY com.tencent.mm/.plugin.appbrand.ui.AppBrandUI 4492c5e pid=16051
oxygen:/ $ ps 16051
USER      PID   PPID  VSIZE  RSS   WCHAN              PC  NAME
u0_a133   16051 800   2403720 227056 SyS_epoll_ 0000000000 S com.tencent.mm:appbrand0
oxygen:/ $

com.tencent.mm:appbrand0即为chromeoptions

'chromeOptions': {'androidProcess': 'com.tencent.mm:appbrand0'}

0x07 踩坑七 ImportError: cannot import name 'InvalidArgumentException'

原因:selenium.common.exceptions.py中未定义InvalidArgumentException类

在C:\anaconda\Lib\site-packages\selenium\common修改excptions.py

参考自:执行appium程序时遇到如下报错,ImportError: cannot import name 'InvalidArgumentException'

0x08 踩坑八 WebDriverException: Message: The URL '/wd/hub//session' did not map to a valid resource


参考自:Appium 1.9 版本 BUG:使用 get_window_size () 方法报错 · TesterHome

0x09 踩坑九 KeyError: 'status'

未解决

参考自:Appium遇到异常处理 

0x10 踩坑十 http://dl-ssl.google.com/android上不去解决方案

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值