Skip to content

Commit d430300

Browse files
author
Administrator
committed
abc
1 parent e866266 commit d430300

File tree

11 files changed

+645
-81
lines changed

11 files changed

+645
-81
lines changed

.idea/Python.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

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

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

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

Python

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit e866266ac8f8544fa7af551df0d0a077d4536aa3

report.html

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<title>教学测试</title>
6+
<meta name="generator" content="HTMLTestRunner 0.8.2"/>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
8+
9+
<style type="text/css" media="screen">
10+
body { font-family: verdana, arial, helvetica, sans-serif; font-size: 80%; }
11+
table { font-size: 100%; }
12+
pre { }
13+
14+
/* -- heading ---------------------------------------------------------------------- */
15+
h1 {
16+
font-size: 16pt;
17+
color: gray;
18+
}
19+
.heading {
20+
margin-top: 0ex;
21+
margin-bottom: 1ex;
22+
}
23+
24+
.heading .attribute {
25+
margin-top: 1ex;
26+
margin-bottom: 0;
27+
}
28+
29+
.heading .description {
30+
margin-top: 4ex;
31+
margin-bottom: 6ex;
32+
}
33+
34+
/* -- css div popup ------------------------------------------------------------------------ */
35+
a.popup_link {
36+
}
37+
38+
a.popup_link:hover {
39+
color: red;
40+
}
41+
42+
.popup_window {
43+
display: none;
44+
position: relative;
45+
left: 0px;
46+
top: 0px;
47+
/*border: solid #627173 1px; */
48+
padding: 10px;
49+
background-color: #E6E6D6;
50+
font-family: "Lucida Console", "Courier New", Courier, monospace;
51+
text-align: left;
52+
font-size: 8pt;
53+
width: 500px;
54+
}
55+
56+
}
57+
/* -- report ------------------------------------------------------------------------ */
58+
#show_detail_line {
59+
margin-top: 3ex;
60+
margin-bottom: 1ex;
61+
}
62+
#result_table {
63+
width: 80%;
64+
border-collapse: collapse;
65+
border: 1px solid #777;
66+
}
67+
#header_row {
68+
font-weight: bold;
69+
color: white;
70+
background-color: #777;
71+
}
72+
#result_table td {
73+
border: 1px solid #777;
74+
padding: 2px;
75+
}
76+
#total_row { font-weight: bold; }
77+
.passClass { background-color: #6c6; }
78+
.failClass { background-color: #c60; }
79+
.errorClass { background-color: #c00; }
80+
.passCase { color: #6c6; }
81+
.failCase { color: #c60; font-weight: bold; }
82+
.errorCase { color: #c00; font-weight: bold; }
83+
.hiddenRow { display: none; }
84+
.testcase { margin-left: 2em; }
85+
86+
87+
/* -- ending ---------------------------------------------------------------------- */
88+
#ending {
89+
}
90+
91+
</style>
92+
93+
</head>
94+
<body>
95+
<script language="javascript" type="text/javascript"><!--
96+
output_list = Array();
97+
98+
/* level - 0:Summary; 1:Failed; 2:All */
99+
function showCase(level) {
100+
trs = document.getElementsByTagName("tr");
101+
for (var i = 0; i < trs.length; i++) {
102+
tr = trs[i];
103+
id = tr.id;
104+
if (id.substr(0,2) == 'ft') {
105+
if (level < 1) {
106+
tr.className = 'hiddenRow';
107+
}
108+
else {
109+
tr.className = '';
110+
}
111+
}
112+
if (id.substr(0,2) == 'pt') {
113+
if (level > 1) {
114+
tr.className = '';
115+
}
116+
else {
117+
tr.className = 'hiddenRow';
118+
}
119+
}
120+
}
121+
}
122+
123+
124+
function showClassDetail(cid, count) {
125+
var id_list = Array(count);
126+
var toHide = 1;
127+
for (var i = 0; i < count; i++) {
128+
tid0 = 't' + cid.substr(1) + '.' + (i+1);
129+
tid = 'f' + tid0;
130+
tr = document.getElementById(tid);
131+
if (!tr) {
132+
tid = 'p' + tid0;
133+
tr = document.getElementById(tid);
134+
}
135+
id_list[i] = tid;
136+
if (tr.className) {
137+
toHide = 0;
138+
}
139+
}
140+
for (var i = 0; i < count; i++) {
141+
tid = id_list[i];
142+
if (toHide) {
143+
document.getElementById('div_'+tid).style.display = 'none'
144+
document.getElementById(tid).className = 'hiddenRow';
145+
}
146+
else {
147+
document.getElementById(tid).className = '';
148+
}
149+
}
150+
}
151+
152+
153+
function showTestDetail(div_id){
154+
var details_div = document.getElementById(div_id)
155+
var displayState = details_div.style.display
156+
// alert(displayState)
157+
if (displayState != 'block' ) {
158+
displayState = 'block'
159+
details_div.style.display = 'block'
160+
}
161+
else {
162+
details_div.style.display = 'none'
163+
}
164+
}
165+
166+
167+
function html_escape(s) {
168+
s = s.replace(/&/g,'&amp;');
169+
s = s.replace(/</g,'&lt;');
170+
s = s.replace(/>/g,'&gt;');
171+
return s;
172+
}
173+
174+
/* obsoleted by detail in <div>
175+
function showOutput(id, name) {
176+
var w = window.open("", //url
177+
name,
178+
"resizable,scrollbars,status,width=800,height=450");
179+
d = w.document;
180+
d.write("<pre>");
181+
d.write(html_escape(output_list[id]));
182+
d.write("\n");
183+
d.write("<a href='javascript:window.close()'>close</a>\n");
184+
d.write("</pre>\n");
185+
d.close();
186+
}
187+
*/
188+
--></script>
189+
190+
<div class='heading'>
191+
<h1>教学测试</h1>
192+
<p class='attribute'><strong>Start Time:</strong> 2019-07-03 20:08:55</p>
193+
<p class='attribute'><strong>Duration:</strong> 0:00:41.773389</p>
194+
<p class='attribute'><strong>Status:</strong> Pass 1 Failure 1</p>
195+
196+
<p class='description'>就是一个教学测试</p>
197+
</div>
198+
199+
200+
201+
<p id='show_detail_line'>Show
202+
<a href='javascript:showCase(0)'>Summary</a>
203+
<a href='javascript:showCase(1)'>Failed</a>
204+
<a href='javascript:showCase(2)'>All</a>
205+
</p>
206+
<table id='result_table'>
207+
<colgroup>
208+
<col align='left' />
209+
<col align='right' />
210+
<col align='right' />
211+
<col align='right' />
212+
<col align='right' />
213+
<col align='right' />
214+
</colgroup>
215+
<tr id='header_row'>
216+
<td>Test Group/Test case</td>
217+
<td>Count</td>
218+
<td>Pass</td>
219+
<td>Fail</td>
220+
<td>Error</td>
221+
<td>View</td>
222+
</tr>
223+
224+
<tr class='failClass'>
225+
<td>YouJiuyeTest</td>
226+
<td>2</td>
227+
<td>1</td>
228+
<td>1</td>
229+
<td>0</td>
230+
<td><a href="javascript:showClassDetail('c1',2)">Detail</a></td>
231+
</tr>
232+
233+
<tr id='pt1.1' class='hiddenRow'>
234+
<td class='none'><div class='testcase'>test_login_password</div></td>
235+
<td colspan='5' align='center'>pass</td>
236+
</tr>
237+
238+
<tr id='ft1.2' class='none'>
239+
<td class='failCase'><div class='testcase'>test_login_username</div></td>
240+
<td colspan='5' align='center'>
241+
242+
<!--css div popup start-->
243+
<a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_ft1.2')" >
244+
fail</a>
245+
246+
<div id='div_ft1.2' class="popup_window">
247+
<div style='text-align: right; color:red;cursor:pointer'>
248+
<a onfocus='this.blur();' onclick="document.getElementById('div_ft1.2').style.display = 'none' " >
249+
[x]</a>
250+
</div>
251+
<pre>
252+
253+
ft1.2: b''b'Traceback (most recent call last):\n File "uniseleniumpra.py", line 27, in test_login_username\n self.assertEqual("\xe8\xb4\xa6\xe5\x8f\xb7\xe4\xb8\x8d\xe5\xad\x98\xe5\x9c\xa8", text, "\xe6\x8f\x90\xe7\xa4\xba\xe5\x86\x85\xe5\xae\xb9\xe6\x9c\x89\xe8\xaf\xaf")\nAssertionError: \'\xe8\xb4\xa6\xe5\x8f\xb7\xe4\xb8\x8d\xe5\xad\x98\xe5\x9c\xa8\' != \'\'\n- \xe8\xb4\xa6\xe5\x8f\xb7\xe4\xb8\x8d\xe5\xad\x98\xe5\x9c\xa8\n+ \n : \xe6\x8f\x90\xe7\xa4\xba\xe5\x86\x85\xe5\xae\xb9\xe6\x9c\x89\xe8\xaf\xaf\n'
254+
255+
</pre>
256+
</div>
257+
<!--css div popup end-->
258+
259+
</td>
260+
</tr>
261+
262+
<tr id='total_row'>
263+
<td>Total</td>
264+
<td>2</td>
265+
<td>1</td>
266+
<td>1</td>
267+
<td>0</td>
268+
<td>&nbsp;</td>
269+
</tr>
270+
</table>
271+
272+
<div id='ending'>&nbsp;</div>
273+
274+
</body>
275+
</html>

selenium_practice.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from selenium import webdriver
2+
from time import sleep
3+
# 实例化一个浏览器驱动
4+
chrome =webdriver.Chrome()
5+
6+
# 访问页面
7+
chrome.get("https://www.baidu.com/")
8+
sleep(1)
9+
# 捕获元素
10+
inputs=chrome.find_element_by_id("kw")
11+
# 对元素进行操作
12+
inputs.send_keys("朱一龙")
13+
button=chrome.find_element_by_id("su")
14+
button.click()
15+
# 关闭浏览器
16+
sleep(10)
17+
chrome.close()

selenium使用.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
from selenium import webdriver
2+
from time import sleep
23

34
#实例化一个浏览器驱动
45
chrome = webdriver.Chrome()
56

67
#访问页面
78
chrome.get("https://www.baidu.com/")
9+
sleep(1)
810
#捕获元素
911
inputs = chrome.find_element_by_id("kw")
1012
#对元素进行操作
1113
inputs.send_keys("老边饺子")
1214
button = chrome.find_element_by_id("su")
1315
button.click()
1416
#关闭浏览器
17+
sleep(10)
1518
chrome.close()
1619

uniseleniumpra.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import unittest
2+
from time import sleep
3+
from selenium import webdriver
4+
from HTMLTestRunner import HTMLTestRunner
5+
6+
class YouJiuyeTest(unittest.TestCase):
7+
def setUp(self):
8+
self.chrome = webdriver.Chrome()
9+
self.chrome.get("http://xue.ujiuye.com/foreuser/login/")
10+
11+
def login(self,username,pasword):
12+
username_d1 = self.chrome.find_element_by_id("username_dl")
13+
password_dl = self.chrome.find_element_by_id("password_dl")
14+
button = self.chrome.find_elements_by_class_name("loginbutton1")
15+
username_d1.send_keys(username)
16+
password_dl.send_keys(pasword)
17+
button[0].click()
18+
text = self.chrome.find_element_by_id("J_usernameTip").text
19+
return text
20+
21+
def test_login_password(self):
22+
text = self.login("13331153361","123")
23+
self.assertEqual("密码应该为6-20位之间!",text,"密码太短提示内容有误")
24+
25+
def test_login_username(self):
26+
text = self.login("13331153361","12345678")
27+
self.assertEqual("账号不存在", text, "提示内容有误")
28+
29+
def tearDown(self):
30+
sleep(10)
31+
self.chrome.close()
32+
33+
if __name__ == '__main__':
34+
suite = unittest.TestSuite()
35+
suite.addTest(YouJiuyeTest("test_login_password"))
36+
suite.addTest(YouJiuyeTest("test_login_username"))
37+
38+
with open("report.html","wb") as f:
39+
runner = HTMLTestRunner(
40+
stream=f,
41+
title="教学测试",
42+
description="就是一个教学测试"
43+
)
44+
runner.run(suite)

0 commit comments

Comments
 (0)