代码如下
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'HONOR H30-L02'
desired_caps['app'] = r'D:\eshop.apk'

desired_caps['app'] = r'D:\epay.apk'

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
print driver.network_connection
driver.close_app()

据说在配置 app 属性的时候不用配 appPackage 和 appActivity 这两个值,我现在这么做了以后就出现了一个问题:
使用 desired_caps['app'] = r'D:\epay.apk'这个配置项的时候可以正常启动 app,使用 desired_caps['app'] = r'D:\eshop.apk'这个配置项就报错,错误信息如下:selenium.common.exceptions.WebDriverException: Message: u"A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity)"

请有了解的人指点一下。谢谢


↙↙↙阅读原文可查看相关链接,并与作者交流