应用程序无法启动appium python

时间:2018-10-09 06:59:20

标签: appium appium-android python-appium

$ adb shell
$ dumpsys window windows | grep -E 'mCurrentFocus'

包装和活动为-mCurrentFocus=Window{120f4c3 u0 in.amazon.mShop.android.shopping/com.amazon.mShop.sso.SigninPromptActivity}
包裹-in.amazon.mShop.android.shopping
主动性-com.amazon.mShop.sso.SigninPromptActivity

我的代码是-

import unittest from appium import webdriver import time class TestClass(unittest.TestCase): def setUp(self): desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['appiumVersion'] = '1.9.0' desired_caps['platformVersion'] = '6.0.1' desired_caps['deviceName'] = 'Moto G3' desired_caps['browserName'] = '' desired_caps['name'] = 'Sample rough' desired_caps['appPackage'] = 'in.amazon.mShop.android.shopping' desired_caps['appActivity'] = 'com.amazon.mShop.sso.SigninPromptActivity' self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

def test_open_App(self): print "======================= START ===============================" print "rough Name : Hello Tester" def tearDown(self): time.sleep(2) self.driver.quit() print "======================= END ==============================="
if __name__ == '__main__': unittest.main()

您能帮我如何启动应用程序吗,我正在尝试与其他应用程序(如 calculator )使用相同的方法,它运行正常,但某些应用程序无法运行,

检查错误代码-链接error response

1 个答案:

答案 0 :(得分:0)

经过研究后,我发现了启动任何应用程序的一些要点,首先,您必须找到要通过应用程序测试启动的应用程序的所有活动,
步骤1:adb shell pm dump PACKAGE_NAME | grep -A 1 <Package Name>
步骤2:使用此命令,尝试通过终端手动启动应用程序

adb shell am start -S -n <Package>/<Activity>

如果您能够启动,然后给出相同的 Package and Activity (包装和活动信息),我建议一一进行活动, package 不会改变,只有活动会改变,启动活动对于启动应用程序非常重要,

您将在终端/命令提示符下找到类似的详细信息
........
................
time="9/10/2018, 12:07 PM" type=MOVE_TO_FOREGROUND package=in.amazon.mShop.android.shopping class=com.amazon.mShop.home.HomeActivity time="9/10/2018, 12:07 PM" type=MOVE_TO_BACKGROUND package=in.amazon.mShop.android.shopping class=com.amazon.mShop.home.HomeActivity time="9/10/2018, 12:07 PM" type=MOVE_TO_FOREGROUND package=in.amazon.mShop.android.shopping class=com.amazon.mShop.home.web.MShopWebGatewayActivity time="9/10/2018, 12:07 PM" type=MOVE_TO_BACKGROUND package=in.amazon.mShop.android.shopping class=com.amazon.mShop.home.web.MShopWebGatewayActivity time="9/10/2018, 12:07 PM" type=MOVE_TO_FOREGROUND package=in.amazon.mShop.android.shopping class=com.amazon.mShop.sso.SigninPromptActivity time="9/10/2018, 12:07 PM" type=MOVE_TO_BACKGROUND package=in.amazon.mShop.android.shopping class=com.amazon.mShop.sso.SigninPromptActivity
........
................

**这里只有一项活动对于通过class=com.amazon.mShop.home.HomeActivity的appium启动很重要

---------我希望它将解决通过appium启动应用程序的问题