Appium APPIUM 求助 : 使用 appium desired_caps ['autoLaunch'] = False,查找元素 Cannot call method 'sendAction' of null

zhang · 2016年06月15日 · 最后由 黑水 回复于 2016年07月03日 · 1206 次阅读

APPIUM 问题求助

描述

不用 appium 启动 activity,使用 appium desired_caps['autoLaunch'] = False,然后用adb shell 命令启动 activity。之后再用使用 appium api 查找元素 就会报错。求助版上的各位大侠。如何解决这个问题呢?

使用的参数代码

desired_caps['automationName'] = 'Appium'
desired_caps['platformName'] = PLATFROM 
desired_caps['platformVersion'] = VERSION 
desired_caps['deviceName'] = DEVICE_SN  
desired_caps['appPackage'] = PACKAGE
desired_caps['appActivity'] = ACTIVITY
desired_caps['autoLaunch'] = False
desired_caps['newCommandTimeout'] = 900  # unit is seconds 
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps, keep_alive=True)
adbShell.start_activity("%s/%s"%(PACKAGE,ACTIVITY))

print self.driver.current_activity  # 成功可以返回当前activity
print self.driver.find_element_by_id("home_score")** # 不成功报错 Cannot call method 'sendAction' of null**
print self.driver.get_window_size() # 不成功报错  Cannot call method 'sendAction' of null
共收到 4 条回复 时间 点赞

使用 markdown 编辑帖子

5楼 已删除

帮你改好啦。。= =

@monkey 谢谢您!

不要用adb启动 activity ,用launch_app()

driver.launch_app()

Launch
Launch the session for the desired capabilities. Note that this is the companion to the autoLaunch=false capability. This is not for launching arbitrary apps/activities—for that use start_activity. This is for continuing the initialization ("launch”) process if you have used autoLaunch=false.

落辰曦 [该话题已被删除] 中提及了此贴 04月30日 17:21
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册