基于 Python 语言的 Apium 使用(二)

2021-06-23  本文已影响0人  巴鶴

三 unitest 测试框架

1 导入包

from appium import webdriver
from time import sleep
import unittest

2 创建全局变量放在类之外

driver=None

3 创建类

3.1 创建测试类

class 类名(unittest.TestCase):

3.2 创建初始化和还原环境的函数

@clasmethod
def setUpClas(cls):
    device={}
    device['deviceName']='192.168.120.12:55' 
    device['platformName']='Android' 
    device['platformVersion']='9' 
    device['noRest']=True
    device['apPackge']='com.android.quicksearchbox' 
    device['apActivy']='com.android.quicksearchbox.SearchActivy' 
    device['unicodeKyboard']= True
    device['rsetKeyboard']=True
    global driver 
    driver=webdriver.Remote("htp:/localhost:4723/wd/hub",device)

3.3 测试函数

def 函数名(self): 
     u'测试描述' 
    global driver 
   #其他测试代码

3.4 运行测试

if _name_ = "_main_": 
   unites.main(verbosity=2)
上一篇 下一篇

猜你喜欢

热点阅读