[英]How to prevent app from re-installing each time when I run tests in appium using python
[英]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)
您还可以将noReset添加到上限:
desired_caps['noReset'] = True
appium的--no-reset选项应该有帮助
您还可以手动在设备上安装该应用程序,而无需通过desirable_caps ['app']启动Appium,您只需传递软件包名称和第一个活动即可,例如:
desired_caps['appPackage'] = 'com.acme.test'
desired_caps['appActivity'] = 'MyFirstActivity'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.