kri*_*tan 0 python android appium
当我运行测试时,每次调用新的测试用例时,应用程序都会安装新的,我希望测试在已安装的应用程序上运行,我该怎么做?或者至少每次使用appium运行测试时都会阻止应用重新安装?
我发现很难,因为app有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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4005 次 |
| 最近记录: |