import unittest
import time
from HTMLTestRunner import HTMLTestRunner
from selenium import webdriver
class testBaseUtils(unittest.TestCase):
# def setUp(self):
# print("start开始")
#
# def tearDown(self):
# # self.wb.quit()
# print("end结束")
def test01(self):
self.wb = webdriver.Firefox()
self.wb.get("http://www.renren.com")
wname = self.wb.find_element_by_name("email")
wname.send_keys("17339333520")
word = self.wb.find_element_by_name("password")
word.send_keys("fan_33520")
self.wb.find_element_by_id("login").click()
print("test1")
def test02(self):
print("test2")
if __name__ == "__main__":
test = unittest.TestSuite()
test.addTest(testBaseUtils('test01'))
test.addTest(testBaseUtils('test02'))
# 格式化时间
current_time = time.strftime("%Y-%m-%d %H_%M_%S")
# 指定测试用例为当前文件夹下的test_Case目录
test_dir = "L:/My_working_space/My_download/pycharmpro/untitled/testHome/sctipts/report"
# 测试报告存放路径
filename = test_dir + "/" + current_time + "test.html"
# 打开测试测试报告文件
fp = open(filename, "wb")
runner = HTMLTestRunner(stream=fp,title="集成测试报告",description="测试执行情况:")
runner.run(test) # 执行测试
# fp.close() # 关闭测试报告文件
print("test0")
tts = testBaseUtils()
tts.test01()
tts.test02()