zoukankan      html  css  js  c++  java
  • 解析BeautifulReport生成的html测试报告

    用于处理BeautifulReport生成的测试报告,提取html文件中的字段信息
    from
    bs4 import BeautifulSoup from setting.config import * import json from string import digits import requests def get_html_info(html_name): ''' 获取测试报告中的内容 param html_name:报告的名称 return:json list ''' htmlname = u'%s/%s' % (REPORT_PATH, html_name) # 获取文件对象 html = BeautifulSoup(open(htmlname, encoding='utf-8'), features='html.parser') # 获取所有的文本 text = html.get_text() # 字符串处理,把一些冗余的字符串处理掉 text = text.replace(' ', '') text = text.replace(' ', '') text = text.split("详细信息")[-1] text = text.split("查看详情") text_list_temp = [] for i in text: if 'Traceback' not in i: text_list_temp.append(i) elif 'Traceback' in i: i = i.split('')[-1] text_list_temp.append(i) # 将结果提取出来,组装成一个列表 res_json_list = [] for text in text_list_temp[0:-1]: suite_name = text.split('Test')[-1].split('test')[0] i = text.split('_')[-1].split("") case_id = i[0][-3:] case_id = int(case_id) case_title = i[1].split('.')[0] # remove digits case_title = case_title.translate(str.maketrans('', '', digits)) # 转换结果 result = i[1].split('s')[-1] if result == '成功': result = 'pass' else: result = 'fail' # 结果组成字典, product_id, task_id res_dict = { # 'product_id': 42440, 'testtask_name':'集成测试', 'suite_name': suite_name, # 'task_id': 43641, 'case_id': case_id, 'test_type':'UI', 'result': result, 'reals': case_title, 'area':'成都', 'user_name': 'mikigo' } # dict —> json res_json = json.dumps(res_dict, ensure_ascii=False) res_json_list.append(res_json) return res_json_list
    没伞的孩子,就要学会在雨中奔跑!
  • 相关阅读:
    深信服入职前编码训练21题--02
    深信服入职前编码训练21题--01
    Leetcode本地阅读器开发--01界面设计三
    Leetcode本地阅读器开发--01界面设计二
    Leetcode本地阅读器开发--01界面设计一
    使用DDMS测试安卓手机APP的性能(android)
    在PC上测试移动端网站和模拟手机浏览器的5大方法
    SeleniumIDE与eclipse如何连接使用
    Selenium RC配置
    Selenium IDE- 不同的浏览器
  • 原文地址:https://www.cnblogs.com/mikigo/p/13930043.html
Copyright © 2011-2022 走看看