Original error: The desired capabilities must include either an app, appPackage or browserName

版权声明:本文为博主原创文章,欢迎转载,转载时请以超链接形式标明文章原始出处。 https://blog.csdn.net/lilongsy/article/details/83000083

问题

用Appium测试报错

selenium.common.exceptions.WebDriverException: 
Message: An unknown server-side error occurred while processing the command. 
Original error: The desired capabilities must include either an app, 
appPackage or browserName

解决

没有找对对应的appPackageappActivity
可以通过cmd运行下面命令:

adb shell dumpsys window w | find "/" | find "name="

就会得到类似下面的信息:

mSurface=Surface(name=com.tencent.mm/com.tencent.mm.plugin.account.ui.LoginPasswordUI)

其中appPackagecom.tencent.mm
appActivitycom.tencent.mm.plugin.account.ui.LoginPasswordUI

完整代码

python代码

from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '8.0'
desired_caps['deviceName'] = 'DU3ADH14C4009842'
# desired_caps['app'] = 'com.iqilu.cloud.MyApplication'
desired_caps['appPackage'] = 'com.tencent.mm'
desired_caps['appActivity'] = 'com.tencent.mm.plugin.account.ui.LoginPasswordUI'

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

猜你喜欢

转载自blog.csdn.net/lilongsy/article/details/83000083