用python和unittest编写app自动化测试用例
Posted #天羽Owl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用python和unittest编写app自动化测试用例相关的知识,希望对你有一定的参考价值。
import unittest import webdriver import time class Test(unittest.TestCase): @classmethod def setUpClass(self): cap = {} cap[\'platformName\'] = \'Android\' cap[\'platformVersion\'] = \'4.4.2\' cap[\'deviceName\'] = \'7N2SSE158P001892\' cap[\'noReset\'] = \'noReset\' cap[\'appPackage\'] = \'com.gomo.calculator\' cap[\'appActivity\'] = \'.ui.activity.MainActivity\' self.driver = webdriver.Remote(\'http://localhost:4723/wd/hub\',cap) @classmethod def tearDownClass(self): self.driver.quit() def test_Add(self): time.sleep(2) self.driver.find_element_by_id(\'com.gomo.calculator:id/input_num_1\').click() self.driver.find_element_by_id(\'com.gomo.calculator:id/display_op_add\').click() self.driver.find_element_by_id(\'com.gomo.calculator:id/input_num_2\').click() self.driver.find_element_by_id(\'com.gomo.calculator:id/display_eq\').click() print("test_Add success!!!") def test_Mul(self): time.sleep(2) self.driver.find_element_by_id(\'com.gomo.calculator:id/input_num_3\').click() self.driver.find_element_by_id(\'com.gomo.calculator:id/op_mul\').click() self.driver.find_element_by_id(\'com.gomo.calculator:id/input_num_4\').click() self.driver.find_element_by_id(\'com.gomo.calculator:id/display_eq\').click() print("test_Mul success!!!") if __name__ == "__main__": #import sys;sys.argv = [\'\', \'Test.testName\'] unittest.main()
java版请移步:用java和junit编写app自动化测试用例
以上是关于用python和unittest编写app自动化测试用例的主要内容,如果未能解决你的问题,请参考以下文章
appium+python+unittest+HTMLRunner编写UI自动化测试集