码迷,mamicode.com
首页 > 移动开发 > 详细

用python和unittest编写app自动化测试用例

时间:2018-01-13 22:30:05      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:gpo   rem   www   assm   lan   get   ase   编写   device   

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

标签:gpo   rem   www   assm   lan   get   ase   编写   device   

原文地址:https://www.cnblogs.com/mgzc-1508873480/p/8280530.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!