用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自动化测试用例

上一篇:Java8学习笔记(六)--Optional


下一篇:最新安全狗 apache v4.0 sql注入 bypass