Exemplo n.º 1
0
    def tearDownClass(self):
        Log('测试用例执行完毕,测试环境正在还原!')
        time.sleep(5)
        self.deriver.quit()

# if __name__ == '__main__':
#     unittest.main()
Exemplo n.º 2
0
def open_da(path):
    try:
        file = open(r'%s'%path,'r',encoding='utf-8')
        data = yaml.load(file)
        return {'code':0,'data':data} 
    except Exception as e:
        Log('yaml文档解析失败!原因:%s'%e)
        return {'code':1,'data':e}
Exemplo n.º 3
0
 def setUp(self):
     """每条用例执行前的初始化"""
     self.driver = webdriver.Chrome()
     self.driver.get(
         'http://192.168.199.235:38092/oauth/authorize?client_id=mJrcghz5g6&response_type=code&redirect_uri=http%3A%2F%2F192.168.199.143%3A17080%2Fgateway'
     )
     self.data_time = datetime.datetime.now().strftime('%Y-%m-%d-%H%M%S')
     self.pngpath = './../report/png/' + date + '/' + self.data_time
     self.log = Log(logpath)
     time.sleep(1)
Exemplo n.º 4
0
def write_recording(cpu,neicun):
    try:
        with open(recording,'a',encoding='utf-8') as f:
            m='cpu:%s,内存:%s'%(cpu,neicun)
            f.write(m+'\n')
            f.close()
    except Exception as e:
        Log('写入性能数据失败!失败原因:%s'%e)


# if __name__ == '__main__':
#     print(caijicpu("com.ss.android.ugc.aweme"))
#     print(getnencun('com.ss.android.ugc.aweme'))
#     write_recording(caijicpu("com.ss.android.ugc.aweme"),getnencun('com.ss.android.ugc.aweme'))
Exemplo n.º 5
0
def huoqu_test(filepath,index):
    # filepath="F:\\python_appium框架\\data\\testcase_data.xlsx"
    # index="0"
    try:
        file = xlrd.open_workbook(filepath)
        me = file.sheets()[index]
        nrows = me.nrows
        listdata = []
        for i in range(1, nrows):
            dict_canshu = {}
            dict_canshu['id']=me.cell(i, 0).value
            dict_canshu['logout']=(me.cell(i,2).value)
            dict_canshu.update(eval(me.cell(i,3).value))
            dict_canshu.update(eval(me.cell(i,4).value))
            listdata.append(dict_canshu)
        return listdata
  
    except Exception as e:
        Log('获取测试用例参数失败!失败原因:%s'%e)
Exemplo n.º 6
0
# encoding: utf-8
#author: hanzilong
import yaml
from untils.log import Log
from untils.py_app import deriver_fengzhuang as feng

Log('解析yaml文件')
def open_da(path):
    try:
        file = open(r'%s'%path,'r',encoding='utf-8')
        data = yaml.load(file)
        return {'code':0,'data':data} 
    except Exception as e:
        Log('yaml文档解析失败!原因:%s'%e)
        return {'code':1,'data':e}
Exemplo n.º 7
0
# encoding: utf-8
#author: hanzilong
'''
获取配置相关手机性能的数据
'''
from untils.log import Log
import platform,os,time
Log('采集cpu信息')
def caijicpu(packagename):#这里采集的cpu时候可以是执行操作采集 就是-n  -d  刷新间隔
	cpu='adb shell top -n 1| findstr %s'%(packagename)
	re_cpu=os.popen(cpu).read().split()[2]
	return re_cpu
Log('获取使用的物理内存信息')
def getnencun(packagename):#Total 的实际使用过物理内存
	cpu = 'adb shell top -n 1| findstr %s' % (packagename)
	re_cpu=os.popen(cpu).read().split()[6]
	re_cpu_m=str(round(int(re_cpu[:-1])/1024))+'M'
	return re_cpu_m

'''采集的性能测试数据存放在txt文档中'''
path=os.getcwd()
now = time.strftime('%Y-%m-%d-%H-%M', time.localtime(time.time()))
recording=path+'\\reports\\%s.txt'%now
Log('记录当前的cpu占有率,内存')
def write_recording(cpu,neicun):
    try:
        with open(recording,'a',encoding='utf-8') as f:
            m='cpu:%s,内存:%s'%(cpu,neicun)
            f.write(m+'\n')
            f.close()
    except Exception as e:
Exemplo n.º 8
0
 def setUpClass(self):
     self.dis_app = make_dis()   #初始配置
     self.img=img()              #截图目录赋值
     self.deriver = webdriver.Remote('http://localhost:4723/wd/hub', self.dis_app)
     time.sleep(15)
     Log('reg测试用例开始执行')
Exemplo n.º 9
0
# encoding: utf-8
#author: hanzilong
'''从Excel获取测试用例相关数据'''
import xlrd
from untils.log import Log
Log('获取测试用例所需要的参数')
def huoqu_test(filepath,index):
    # filepath="F:\\python_appium框架\\data\\testcase_data.xlsx"
    # index="0"
    try:
        file = xlrd.open_workbook(filepath)
        me = file.sheets()[index]
        nrows = me.nrows
        listdata = []
        for i in range(1, nrows):
            dict_canshu = {}
            dict_canshu['id']=me.cell(i, 0).value
            dict_canshu['logout']=(me.cell(i,2).value)
            dict_canshu.update(eval(me.cell(i,3).value))
            dict_canshu.update(eval(me.cell(i,4).value))
            listdata.append(dict_canshu)
        return listdata
  
    except Exception as e:
        Log('获取测试用例参数失败!失败原因:%s'%e)
Exemplo n.º 10
0
# encoding: utf-8
# author: hanzilong
'''主运行文件'''
from untils.HTMLTestReportCN import HTMLTestRunner
import os, unittest, time
from untils.log import Log
from config import casepy
# import untils.emails

#运行测试脚本,生成Html测试报告
Log('UI自动化相关测试开始执行')
test_suit = unittest.TestSuite()
discover = unittest.defaultTestLoader.discover(casepy(),
                                               pattern='test*.py',
                                               top_level_dir=None)  #运行整目录文件
for test in discover:
    for test_case in test:
        test_suit.addTest(test_case)
now = time.strftime('%Y-%m-%d %Hh_%Mm', time.localtime(time.time()))
filename = os.getcwd() + "\\reports\\" + now + "_report.html"
re_open = open(filename, 'wb')
runer = HTMLTestRunner(stream=re_open,
                       title=u'APP自动化测试报告',
                       description=u'自动化用例执行情况:',
                       tester=u'hanzilong',
                       verbosity=2)
runer.run(test_suit)
re_open.close()
Log('UI自动化相关测试执行完毕!')

#  邮件发送配置