import os
from selenium import webdriver

PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p)
)

desired_caps = {}
desired_caps['deviceName'] = '2013022'
desired_caps['platformName'] = 'Android'
desired_caps['browserName'] = ''
desired_caps['version'] = '4.2'
desired_caps['app'] = r'C:\Users\mazhigang\Desktop\AndroidStorm.apk'
desired_caps['appPackage'] = 'com.storm.smart'
desired_caps['appActivity'] = '.StormApplication'

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

这是报错:
selenium.common.exceptions.WebDriverException: Message: u"A new session could no
t be created. (Original error: Activity used to start app doesn't exist or canno
t be launched! Make sure it exists and is a launchable activity)"

运行这个脚本已经能自动安装应用了,然后包这个错误。


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