每次我使用 python 在 appium 中运行测试时,如何防止应用程序安装?

How to prevent app from installing every time i run an test in appium using python?

当我运行测试时,每次调用新的测试用例时都会重新安装应用程序,我希望测试在已安装的应用程序上运行,我该怎么做?? 或者至少防止每次使用 appium 运行测试时重新安装应用程序?

我觉得很难,因为应用程序有8页的欢迎屏幕,每次重新安装应用程序都必须编写代码来滑动欢迎屏幕和欢迎消息。 这是我的代码

import os

from time import sleep


import unittest

from appium import webdriver


# Returns absolute path relative to this file and not cwd
    PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p))
class SimpleAndroidTests(unittest.TestCase):
    def setUp(self):
        desired_caps = {}
#Specify platform below(Android, iOS)
        desired_caps['platformName'] = 'Android'
#Specify OS version(Settings->About phone -> android version)
        desired_caps['platformVersion'] = '4.4.4'
#Obtain the Device name from Adb[For Android](Terminal Command: "adb devices")
        desired_caps['deviceName'] = 'TA93304QZD'
#Specify the path to Application
        desired_caps['app'] = PATH('Media Drive-com.sandisk.scotti-55-v2.0.3.apk')

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

    def tearDown(self):
        # end the session
    self.driver.quit()

    def test_images_copy(self):
        self.driver.implicitly_wait(5)

        for i in range(0,4):
            self.driver.find_element_by_id("com.sandisk.scotti:id/txt_Next").click()
            self.driver.implicitly_wait(5)
        self.driver.find_element_by_id("com.sandisk.scotti:id/txt_Close").click()
        self.driver.implicitly_wait(5)
        self.driver.find_element_by_name("OK").click()
        self.driver.implicitly_wait(5)
        self.driver.find_element_by_id("com.sandisk.scotti:id/txt_Photo").click()
        self.driver.implicitly_wait(5)
        self.driver.find_element_by_id("com.sandisk.scotti:id/btn_Switch_Local").click()
        self.driver.implicitly_wait(5)
        self.driver.find_element_by_id("com.sandisk.scotti:id/txt_Name").click()
        self.driver.implicitly_wait(5)
if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(SimpleAndroidTests)
    unittest.TextTestRunner(verbosity=2).run(suite)

appium 的 --no-reset 选项应该有所帮助

你也可以给caps加上noReset:

desired_caps['noReset'] = True

您也可以在您的设备上手动安装该应用程序,而不是使用 desired_caps['app'] 启动 Appium,您可以只传递包名称和第一个 activity,这样:

desired_caps['appPackage'] = 'com.acme.test'
desired_caps['appActivity'] = 'MyFirstActivity'