阳洁
2023-07-13 2895a64905b07b2f16fa890773c9475290f88630
测评系统自动测试
2个文件已修改
48 ■■■■ 已修改文件
report/report.html 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
testcase/test_smoking.py 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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">
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
        # 浏览器窗口最大化
        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()