From 2895a64905b07b2f16fa890773c9475290f88630 Mon Sep 17 00:00:00 2001
From: 阳洁 <2077506045@qq.com>
Date: 星期四, 13 七月 2023 14:35:53 +0800
Subject: [PATCH] 测评系统自动测试

---
 testcase/test_smoking.py |   22 +++++++++++++++++++++-
 report/report.html       |   26 +++++++++++++-------------
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/report/report.html b/report/report.html
index 5635d9d..40651a1 100644
--- a/report/report.html
+++ b/report/report.html
@@ -253,10 +253,10 @@
 }
 </script>
     <h1>report.html</h1>
-    <p>Report generated on 12-Jul-2023 at 16:29:07 by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a> v3.2.0</p>
+    <p>Report generated on 13-Jul-2023 at 14:10:29 by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a> v3.2.0</p>
     <h2>Summary</h2>
-    <p>4 tests ran in 65.45 seconds. </p>
-    <p class="filter" hidden="true">(Un)check the boxes to filter the results.</p><input checked="true" class="filter" data-test-result="passed" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="passed">4 passed</span>, <input checked="true" class="filter" data-test-result="skipped" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="skipped">0 skipped</span>, <input checked="true" class="filter" data-test-result="failed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="failed">0 failed</span>, <input checked="true" class="filter" data-test-result="error" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="error">0 errors</span>, <input checked="true" class="filter" data-test-result="xfailed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="xfailed">0 expected failures</span>, <input checked="true" class="filter" data-test-result="xpassed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="xpassed">0 unexpected passes</span>
+    <p>4 tests ran in 5.98 seconds. </p>
+    <p class="filter" hidden="true">(Un)check the boxes to filter the results.</p><input checked="true" class="filter" data-test-result="passed" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="passed">1 passed</span>, <input checked="true" class="filter" data-test-result="skipped" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="skipped">0 skipped</span>, <input checked="true" class="filter" data-test-result="failed" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="failed">3 failed</span>, <input checked="true" class="filter" data-test-result="error" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="error">0 errors</span>, <input checked="true" class="filter" data-test-result="xfailed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="xfailed">0 expected failures</span>, <input checked="true" class="filter" data-test-result="xpassed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="xpassed">0 unexpected passes</span>
     <h2>Results</h2>
     <table id="results-table">
       <thead id="results-table-head">
@@ -267,29 +267,29 @@
           <th class="sortable links" col="links">Links</th></tr>
         <tr hidden="true" id="not-found-message">
           <th colspan="4">No results found. Try to check the filters</th></tr></thead>
-      <tbody class="passed results-table-row">
+      <tbody class="failed results-table-row">
         <tr>
-          <td class="col-result">Passed</td>
+          <td class="col-result">Failed</td>
           <td class="col-name">testcase/test_smoking.py::TestSmoking::test_login</td>
-          <td class="col-duration">4.52</td>
+          <td class="col-duration">4.36</td>
           <td class="col-links"></td></tr>
         <tr>
           <td class="extra" colspan="4">
             <div class="empty log">No log output captured.</div></td></tr></tbody>
-      <tbody class="passed results-table-row">
+      <tbody class="failed results-table-row">
         <tr>
-          <td class="col-result">Passed</td>
+          <td class="col-result">Failed</td>
           <td class="col-name">testcase/test_smoking.py::TestSmoking::test_create_package</td>
-          <td class="col-duration">8.38</td>
+          <td class="col-duration">0.00</td>
           <td class="col-links"></td></tr>
         <tr>
           <td class="extra" colspan="4">
             <div class="empty log">No log output captured.</div></td></tr></tbody>
-      <tbody class="passed results-table-row">
+      <tbody class="failed results-table-row">
         <tr>
-          <td class="col-result">Passed</td>
+          <td class="col-result">Failed</td>
           <td class="col-name">testcase/test_smoking.py::TestSmoking::test_open_url</td>
-          <td class="col-duration">6.30</td>
+          <td class="col-duration">0.00</td>
           <td class="col-links"></td></tr>
         <tr>
           <td class="extra" colspan="4">
@@ -298,7 +298,7 @@
         <tr>
           <td class="col-result">Passed</td>
           <td class="col-name">testcase/test_smoking.py::TestSmoking::test_answer</td>
-          <td class="col-duration">46.21</td>
+          <td class="col-duration">8.81</td>
           <td class="col-links"></td></tr>
         <tr>
           <td class="extra" colspan="4">
diff --git a/testcase/test_smoking.py b/testcase/test_smoking.py
index 9114f4e..64b4f68 100644
--- a/testcase/test_smoking.py
+++ b/testcase/test_smoking.py
@@ -1,5 +1,6 @@
 from datetime import datetime
 import time
+from selenium.webdriver.common.by import By
 
 import pytest
 from selenium import webdriver
@@ -24,8 +25,27 @@
         TestSmoking.driver = webdriver.Chrome()
         driver = TestSmoking.driver
         login_page = LoginPage(driver)
-        driver.get("http://47.114.179.216:8090/login?lang=zh_CN")
+        try:
+            # 鎵撳紑閾炬帴
+            driver.get("http://161.117.57.194/login?lang=zh_CN")
+        except:
+            # 閾炬帴鎵撳紑鍑虹幇寮傚父璇存槑閾炬帴鏃犳硶璁块棶,鎹曡幏寮傚父浣嗕笉鍋氬鐞�
+            pass
+
+        # 娴忚鍣ㄧ獥鍙f渶澶у寲
         driver.maximize_window()
+        # 鑾峰彇鍒板埛鏂版寜閽苟姣�10绉掔偣鍑讳竴娆�,鐭ラ亾鍒锋柊鎸夐挳娑堝け
+        while True:
+            try:
+                # 鍒ゆ柇鎵撳紑鐨勯〉闈㈡槸鍚﹀瓨鍦ㄥ埛鏂版寜閽�
+                reload_btn = login_page.get_element((By.XPATH, "//div[@id='buttons']/div/button[@id='reload-button']"))
+                # 鐐瑰嚮鍒锋柊鎸夐挳
+                reload_btn.click()
+                time.sleep(10)
+            except:
+                # 鍑虹幇寮傚父琛ㄧず涓嶅瓨鍦ㄥ埛鏂版寜閽�,閫�鍑哄惊鐜�
+                break
+
         login_page.login("admin", "HyNc#jp0z#N7Y5ih", "ots")
         time.sleep(2)
         assert login_page.is_login_success()

--
Gitblit v1.9.1