我想在appium中創建一些測試,但是當我第一次運行應用程序時,我必須通過使用條款屏幕並首先運行屏幕。在appium中,我如何將測試用作另一個測試的依賴項,而無需一直運行它?
由於我只需要運行一次這些步驟,我有一些困難的時間來運行其他測試(當我已經運行這些屏幕)。
任何想法,我該如何做到這一點?
import os, unittest, time
from appium import webdriver
from time import sleep
class Tests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '0429058934'
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'mypath'))
desired_caps['appPackage'] = ''
desired_caps['appActivity'] = '.MainActivity'
desired_caps['fullReset'] = True
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
self.driver.implicitly_wait(30)
def tearDown(self):
self.driver.quit()
def first_run(self):
self.driver.find_element_by_id("p_agreement_btn").click()
next = self.driver.find_element_by_id("next_text")
next.click()
next.click()
next.click()
next.click()
self.driver.find_element_by_id("btn_ok").click()
def test_optimization(self):
self.driver.find_element_by_id("new_powerpro_tab_view_text").click()
self.driver.find_element_by_id("optimization_button").click()
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(Tests)
unittest.TextTestRunner(verbosity=2).run(suite)
請提供更多關於鏈接的信息。 –
您正在使用UnitTest框架的python,它不像TestNg那樣支持依賴關係。如果你想創建依賴測試,那麼你使用Proboscis測試框架,它具有與TestNg相同的功能。通過上面的鏈接讀取文檔特別註釋,如「@test(depends_on = [UserTests.successful_login])」 –
在回答中更新它。 –