Skip to content

Commit 8872332

Browse files
author
LaoBian
committed
v4 htmltestrunner结合selenium
1 parent e866266 commit 8872332

4 files changed

Lines changed: 124 additions & 34 deletions

File tree

.idea/workspace.xml

Lines changed: 77 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

geckodriver.log

Whitespace-only changes.

report.html

Whitespace-only changes.

unittest_selenium使用.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,45 @@
3939

4040
#=====================================================================================================
4141

42+
# import unittest
43+
# from time import sleep
44+
# from selenium import webdriver
45+
#
46+
# class YouJiuyeTest(unittest.TestCase):
47+
# def setUp(self):
48+
# self.chrome = webdriver.Chrome()
49+
# self.chrome.get("http://xue.ujiuye.com/foreuser/login/")
50+
#
51+
# def login(self,username,pasword):
52+
# username_d1 = self.chrome.find_element_by_id("username_dl")
53+
# password_dl = self.chrome.find_element_by_id("password_dl")
54+
# button = self.chrome.find_elements_by_class_name("loginbutton1")
55+
# username_d1.send_keys(username)
56+
# password_dl.send_keys(pasword)
57+
# button[0].click()
58+
# text = self.chrome.find_element_by_id("J_usernameTip").text
59+
# return text
60+
#
61+
# def test_login_password(self):
62+
# text = self.login("13331153361","123")
63+
# self.assertEqual("密码应该为6-20位之间!",text,"密码太短提示内容有误")
64+
#
65+
# def test_login_username(self):
66+
# text = self.login("13331153361","12345678")
67+
# self.assertEqual("账号不存在", text, "提示内容有误")
68+
#
69+
# def tearDown(self):
70+
# sleep(10)
71+
# self.chrome.close()
72+
#
73+
# if __name__ == '__main__':
74+
# unittest.main()
75+
76+
4277
import unittest
4378
from time import sleep
4479
from selenium import webdriver
80+
from HTMLTestRunner import HTMLTestRunner
4581

4682
class YouJiuyeTest(unittest.TestCase):
4783
def setUp(self):
@@ -71,4 +107,14 @@ def tearDown(self):
71107
self.chrome.close()
72108

73109
if __name__ == '__main__':
74-
unittest.main()
110+
suite = unittest.TestSuite()
111+
suite.addTest(YouJiuyeTest("test_login_password"))
112+
suite.addTest(YouJiuyeTest("test_login_username"))
113+
114+
with open("report.html","wb") as f:
115+
runner = HTMLTestRunner(
116+
stream=f,
117+
title="教学测试",
118+
description="就是一个教学测试"
119+
)
120+
runner.run(suite)

0 commit comments

Comments
 (0)