m0_68760792
2022-05-03 00:12
采纳率: 50%
浏览 39
已结题

测试学员,希望大家为我解惑,这代码困扰我一天了,谢!

from HTMLTestRunner import HTMLTestRunner
import os
import time
import unittest
from ddt import ddt, data, unpack
from selenium import webdriver
import openpyxl

def read():
workbook = openpyxl.load_workbook('工作簿1.xlsx')
table = workbook['Sheet1']
zz = table.max_row
xx = table.max_column
alis = []
for i in range(1, zz + 1):
lis = []
for j in range(1, xx + 1):
lis.append(table.cell(i, j).value)
alis.append(lis)
return alis

@ddt
class Application(unittest.TestCase):
@data(*read())
@unpack
def test01_app(self, id, name, passwd):
print(id, name, passwd)
self.id = id
self.name = name
self.passwd = passwd
a = webdriver.Firefox()
a.get('https://mail.qq.com/')
a.switch_to.frame('login_frame')
a.find_element_by_id('u').send_keys(name)
a.find_element_by_id('p').send_keys(passwd)
a.find_element_by_id('login_button').click()
time.sleep(1)
a.quit()
def test02_app(self):
print('abc')
if name == 'main':
b = unittest.TestSuite()
b.addTest(Application('test01_app'))
file = open(os.getcwd() + '/report.html', 'wb')
c = HTMLTestRunner(stream=file, verbosity=2, title='我的表格', description='报告如下:')
c.run(b)
1 admin 123456
2 admin 123456
3 123456 123456
上面这个是xlsx表格,名字叫:工作簿1.xlsx

1条回答 默认 最新

相关推荐 更多相似问题