我们需要4个文件:
1. 234.xlsx # Excel表格数据
2. readexcel.py # 读取excel表格数据
3. requestexcel.py # 获取请求之后的code
4. testexcel.py # 使用allure生成测试报告
1. 234.xlsx
Excel表格数据,这里将第一个url改成错误的了,为了演示错误的url,会返回404状态码。
2. readexcel.py
from openpyxl import load_workbook # 导包,没有的话 pip install openpyxl
class UseExcel():
def get_TestExcel(self):
# 打开表
workbook = load_workbook(r'C:\Users\JinYan\Desktop\自动化代码\requeststext\datademo\234.xlsx')
# 定位表单
sheet = workbook['Sheet1']
print(sheet.max_row) #3 行