提交 0fe20cca authored 作者: 陈泽健's avatar 陈泽健

完成毫米波雷达的模拟数据上报,系统界面根据上报信息来回显,目前只造了100个模拟数据。

上级 537ccdc1
......@@ -292,7 +292,7 @@ class Mqtt:
})
#毫米波雷达数据上报
elif "/properties/upload" in topic or "/properties/upload" in topic:
elif "/properties/upload" in topic or "/event/upload" in topic:
return json.dumps({
"properties":{
"client_id" : config['client_id'],
......@@ -304,7 +304,7 @@ class Mqtt:
"wifi_mac" : config['wifi_mac'],
"ble_mac" : config['ble_mac'],
"last_connection_time": current_time,
"current_time":"2024-08-28 17:21:36",
"current_time":current_time,
"device_model" : "c1_100_wifi_u",
"fw_version":"0.0.6",
"sn" : config['sn'],
......
......@@ -3,6 +3,7 @@ from hytest import *
from selenium import webdriver
from selenium.common import TimeoutException, NoSuchElementException, ElementNotInteractableException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
......@@ -65,15 +66,10 @@ def enter_the_backend():
wd = GSTORE['wd']
safe_click((By.XPATH, "//img[@title='后台系统']"), wd)
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
def safe_send_keys(element_locator, value, wd):
try:
element = WebDriverWait(wd, 10).until(EC.visibility_of_element_located(element_locator))
element.clear()
element.send_keys(value)
except TimeoutException:
print(f"TimeoutException: Element {element_locator} not found or not clickable within 10 seconds.")
......@@ -86,6 +82,17 @@ def safe_click(element_locator, wd):
try:
element = WebDriverWait(wd, 10).until(EC.visibility_of_element_located(element_locator))
element.click()
except TimeoutException:
INFO(f"TimeoutException: Element {element_locator} not found or not clickable within 10 seconds.")
except NoSuchElementException:
INFO(f"NoSuchElementException: Element {element_locator} not found.")
except ElementNotInteractableException:
INFO(f"ElementNotInteractableException: Element {element_locator} is not interactable.")
def input_clear(element_locator, wd):
try:
input_element = WebDriverWait(wd, 10).until(EC.visibility_of_element_located(element_locator))
input_element.clear()
except TimeoutException:
print(f"TimeoutException: Element {element_locator} not found or not clickable within 10 seconds.")
except NoSuchElementException:
......@@ -93,6 +100,7 @@ def safe_click(element_locator, wd):
except ElementNotInteractableException:
print(f"ElementNotInteractableException: Element {element_locator} is not interactable.")
def browser_quit():
INFO("清除浏览器")
wd = GSTORE['wd']
......
......@@ -25,4 +25,6 @@
- 补充用户管理模块的新增用户部分代码,当前存在新增界面弹窗后定位失败问题。
7. 2024-11-04
- 将用户管理模块的代码进行重构,将新增用户、删除用户、修改用户等公用的操作封装到base目录下,方便后续管理。
- 使用元素定位插件进行定位,解决定位失败的问题。
\ No newline at end of file
- 使用元素定位插件进行定位,解决定位失败的问题。
- 测试报告中补充用例截图。
- 完成毫米波雷达的模拟数据上报,系统界面根据上报信息来回显,目前只造了100个模拟数据。
\ No newline at end of file
......@@ -16,7 +16,9 @@ except ModuleNotFoundError as e:
from 预定系统.Base.base import *
def suite_setup():
STEP(1, "初始化浏览器")
browser_init()
STEP(2, "处理SSL认证")
handle_ssl_warning()
def suite_teardown():
......
......@@ -49,6 +49,7 @@ if __name__ == "__main__":
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
message = Mqtt.build_message(config, current_time, topic)
logging.info(message)
# 发送消息
mqtt_client.publish(topic, message)
......
......@@ -16,5 +16,16 @@ except ModuleNotFoundError as e:
from 预定系统.Base.base import *
def suite_setup():
wd = GSTORE['wd']
STEP(3,"管理员登录系统")
admin_login()
enter_the_backend()
\ No newline at end of file
SELENIUM_LOG_SCREEN(wd)
STEP(4,"进入后台管理页面")
enter_the_backend()
SELENIUM_LOG_SCREEN(wd)
INFO("打开账号管理下拉菜单")
safe_click((By.XPATH, "//span[@class='aside_menu menu_account']"), wd)
INFO("进入用户管理模块")
safe_click((By.XPATH, "//li[contains(text(),'用户管理')]"), wd)
SELENIUM_LOG_SCREEN(wd)
\ No newline at end of file
......@@ -221,17 +221,19 @@ class Add_User_00x:
# 从全局存储中获取webdriver实例
wd = GSTORE['wd']
# 从self.para中解构出用户名、密码、验证码和检查文本
name = self.name
account, username, password, check_password, department, gender, phone, email, check_text = self.para
STEP(1, "点击【新增】按钮")
WebDriverWait(wd, 10).until(
EC.element_to_be_clickable(
(By.XPATH, '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[2]/button[2]/span')
)).click()
sleep(1)
# wd = handle_modal_popup(wd)
STEP(5, "点击【新增】按钮")
if name == '用户新增_001':
safe_click((By.XPATH, "//span[contains(text(),'添 加')]"), wd)
sleep(1)
STEP(2,
elif check_text == '操作成功':
safe_click((By.XPATH, "//span[contains(text(),'添 加')]"), wd)
sleep(1)
STEP(6,
f"输入账号:{account},用户名:{username},密码:{password},确认密码: {check_password},手机号:{phone},邮箱:{email}")
if account is not None:
......@@ -246,6 +248,10 @@ class Add_User_00x:
if check_password is not None:
safe_send_keys((By.XPATH, "//input[@placeholder='确认密码']"), check_password, wd)
#清除下拉框数据
if name != '用户新增_001':
input_clear((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请选择']"),wd)
safe_click((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请选择']"), wd)
safe_click((By.XPATH, "/html[1]/body[1]/div[4]/div[1]/div[1]/div[1]/ul[1]/li[1]/label[1]/span[1]/span[1]"), wd)
safe_click((By.XPATH, "//span[contains(text(),'男')]"), wd)
......@@ -254,7 +260,7 @@ class Add_User_00x:
safe_send_keys((By.XPATH, "//input[@placeholder='邮箱']"), email, wd)
SELENIUM_LOG_SCREEN(wd)
STEP(3, "点击【确定】按钮")
STEP(7, "点击【确定】按钮")
safe_click((By.XPATH, "//div[@aria-label='添加用户']//span[contains(text(),'确定')]"), wd)
time.sleep(2)
......@@ -268,9 +274,9 @@ class Add_User_00x:
INFO(f"Alert text: {notify_text}")
STEP(4, f"校验提示信息: {check_text}")
STEP(8, f"校验提示信息: {check_text}")
# 设置隐式等待时间
wd.implicitly_wait(DEFAULT_WAIT_TIME)
# 检查点:验证提示信息是否与预期相符
CHECK_POINT('弹出提示', notify_text == check_text)
CHECK_POINT('弹出提示', notify_text == check_text)
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -309,19 +309,19 @@ function next_error(){
</tr>
<tr>
<td>开始时间</td>
<td>2024/11/02 22:13:15</td>
<td>2024/11/04 16:03:10</td>
</tr>
<tr>
<td>结束时间</td>
<td>2024/11/02 22:13:37</td>
<td>2024/11/04 16:03:23</td>
</tr>
<tr>
<td>耗时</td>
<td>21.543</td>
<td>13.522</td>
</tr>
<tr>
<td>预备执行用例数量</td>
<td>1</td>
<td>9</td>
</tr>
<tr>
<td>实际执用例行数量</td>
......@@ -341,7 +341,7 @@ function next_error(){
</tr>
<tr>
<td>阻塞</td>
<td style="color:red">1</td>
<td style="color:red">9</td>
</tr>
<tr>
<td>套件初始化失败</td>
......@@ -381,7 +381,7 @@ function next_error(){
</div>
</div>
<div class="barchar_item">
<span>用例阻塞 100% : 1</span>
<span>用例阻塞 100% : 9</span>
<div class="barchart_barbox">
<div class="barchart_bar" style="width: 100.0%; background-color: #dcbdbd;"></div>
</div>
......@@ -401,7 +401,7 @@ function next_error(){
<div class="folder_header">
<span class="label">套件初始化</span>
<span>cases\</span>
<span class="executetime">2024-11-02 22:13:15</span>
<span class="executetime">2024-11-04 16:03:10</span>
</div>
<div class="folder_body">
<div class="info">'----------' 正在初始化浏览器 '----------'</div>
......@@ -419,71 +419,19 @@ function next_error(){
<div class="folder_header">
<span class="label">套件初始化</span>
<span>cases\账号管理\</span>
<span class="executetime">2024-11-02 22:13:24</span>
<span class="executetime">2024-11-04 16:03:21</span>
</div>
<div class="folder_body">
<div class="info">输入用户名:admin@czj</div>
<div class="info">输入密码:Ubains@4321</div>
<div class="info">输入验证码:csba</div>
<div class="info">点击登录按钮</div>
<div class="info">进入后台</div>
<div class="info">进入后台</div>
<div class="info">打开账号管理下拉菜单</div>
<div class="info error-info">suite setup fail | Message:
Stacktrace:
GetHandleVerifier [0x00007FF63C4DFD55+29557]
(No symbol) [0x00007FF63C4521F0]
(No symbol) [0x00007FF63C30B6EA]
(No symbol) [0x00007FF63C35FA15]
(No symbol) [0x00007FF63C35FC6C]
(No symbol) [0x00007FF63C3ABB07]
(No symbol) [0x00007FF63C38753F]
(No symbol) [0x00007FF63C3A88A3]
(No symbol) [0x00007FF63C3872A3]
(No symbol) [0x00007FF63C3512DF]
(No symbol) [0x00007FF63C352451]
GetHandleVerifier [0x00007FF63C80DC4D+3363437]
GetHandleVerifier [0x00007FF63C859AD7+3674359]
GetHandleVerifier [0x00007FF63C84EA7B+3629211]
GetHandleVerifier [0x00007FF63C59FC16+815670]
(No symbol) [0x00007FF63C45D69F]
(No symbol) [0x00007FF63C459264]
(No symbol) [0x00007FF63C459400]
(No symbol) [0x00007FF63C4481AF]
BaseThreadInitThunk [0x00007FFD832E257D+29]
RtlUserThreadStart [0x00007FFD83FCAF08+40]
<div class="info">输入用户名:admin@ZDH</div>
<div class="info error-info">suite setup fail | 'NoneType' object has no attribute 'send_keys'
Traceback:
File &quot;D:\GithubData\自动化脚本-3\ubains-module-test\预定系统\cases\账号管理\__st__.py&quot;, line 20, in suite_setup
enter_the_backend()
File &quot;D:\GithubData\自动化脚本-3\ubains-module-test\预定系统\Base\base.py&quot;, line 90, in enter_the_backend
WebDriverWait(wd, 10).until(
File &quot;C:\Users\29194\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\support\wait.py&quot;, line 105, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
GetHandleVerifier [0x00007FF63C4DFD55+29557]
(No symbol) [0x00007FF63C4521F0]
(No symbol) [0x00007FF63C30B6EA]
(No symbol) [0x00007FF63C35FA15]
(No symbol) [0x00007FF63C35FC6C]
(No symbol) [0x00007FF63C3ABB07]
(No symbol) [0x00007FF63C38753F]
(No symbol) [0x00007FF63C3A88A3]
(No symbol) [0x00007FF63C3872A3]
(No symbol) [0x00007FF63C3512DF]
(No symbol) [0x00007FF63C352451]
GetHandleVerifier [0x00007FF63C80DC4D+3363437]
GetHandleVerifier [0x00007FF63C859AD7+3674359]
GetHandleVerifier [0x00007FF63C84EA7B+3629211]
GetHandleVerifier [0x00007FF63C59FC16+815670]
(No symbol) [0x00007FF63C45D69F]
(No symbol) [0x00007FF63C459264]
(No symbol) [0x00007FF63C459400]
(No symbol) [0x00007FF63C4481AF]
BaseThreadInitThunk [0x00007FFD832E257D+29]
RtlUserThreadStart [0x00007FFD83FCAF08+40]
File &quot;D:\GithubData\自动化脚本-3\ubains-module-test\预定系统\cases\账号管理\__st__.py&quot;, line 19, in suite_setup
admin_login()
File &quot;D:\GithubData\自动化脚本-3\ubains-module-test\预定系统\Base\base.py&quot;, line 51, in admin_login
safe_send_keys((By.XPATH, &quot;//input[@placeholder='请输入账号或手机号或邮箱号']&quot;),'admin@ZDH', wd)
File &quot;D:\GithubData\自动化脚本-3\ubains-module-test\预定系统\Base\base.py&quot;, line 77, in safe_send_keys
element.send_keys(value)
AttributeError: 'NoneType' object has no attribute 'send_keys'
</div>
</div>
</div>
......@@ -491,7 +439,7 @@ Stacktrace:
<div class="folder_header">
<span class="label">套件清除</span>
<span>cases\</span>
<span class="executetime">2024-11-02 22:13:35</span>
<span class="executetime">2024-11-04 16:03:21</span>
</div>
<div class="folder_body">
<div class="info">清除浏览器</div>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -309,15 +309,15 @@ function next_error(){
</tr>
<tr>
<td>开始时间</td>
<td>2024/11/04 10:26:30</td>
<td>2024/11/04 19:24:51</td>
</tr>
<tr>
<td>结束时间</td>
<td>2024/11/04 10:26:42</td>
<td>2024/11/04 19:25:04</td>
</tr>
<tr>
<td>耗时</td>
<td>11.819</td>
<td>12.881</td>
</tr>
<tr>
<td>预备执行用例数量</td>
......@@ -401,10 +401,18 @@ function next_error(){
<div class="folder_header">
<span class="label">套件初始化</span>
<span>cases\</span>
<span class="executetime">2024-11-04 10:26:30</span>
<span class="executetime">2024-11-04 19:24:51</span>
</div>
<div class="folder_body">
<div class="case_step">
<span class="tag">步骤 #1</span>
<span>初始化浏览器</span>
</div>
<div class="info">'----------' 正在初始化浏览器 '----------'</div>
<div class="case_step">
<span class="tag">步骤 #2</span>
<span>处理SSL认证</span>
</div>
<div class="info">'----------' 正在处理SSL证书警告 '----------'</div>
<div class="info">'----------' SSL证书警告处理完成 '----------'</div>
</div>
......@@ -419,16 +427,33 @@ function next_error(){
<div class="folder_header">
<span class="label">套件初始化</span>
<span>cases\账号管理\</span>
<span class="executetime">2024-11-04 10:26:33</span>
<span class="executetime">2024-11-04 19:24:55</span>
</div>
<div class="folder_body">
<div class="case_step">
<span class="tag">步骤 #3</span>
<span>管理员登录系统</span>
</div>
<div class="info">输入用户名:admin@ZDH</div>
<div class="info">输入密码:Ubains@4321</div>
<div class="info">输入验证码:csba</div>
<div class="info">点击登录按钮</div>
<div>
<img class="screenshot" src="imgs/20241104192455746219.png" width="aa">
</div>
<div class="case_step">
<span class="tag">步骤 #4</span>
<span>进入后台管理页面</span>
</div>
<div class="info">进入后台</div>
<div>
<img class="screenshot" src="imgs/20241104192456359052.png" width="aa">
</div>
<div class="info">打开账号管理下拉菜单</div>
<div class="info">进入用户管理模块</div>
<div>
<img class="screenshot" src="imgs/20241104192457125606.png" width="aa">
</div>
</div>
</div>
</div>
......@@ -441,33 +466,33 @@ function next_error(){
<div class="folder_header">
<span class="label caselabel">用例 PASS</span>
<span class="casename">用户新增_001</span>
<span class="executetime">2024-11-04 10:26:35</span>
<span class="executetime">2024-11-04 19:24:57</span>
</div>
<div class="folder_body">
<span class="case_class_path">cases\账号管理\用户管理.py::Add_User_00x</span>
<div class="test_steps" id="test_steps 用户新增_001">
<span class="label">测试步骤</span>
<div class="case_step">
<span class="tag">步骤 #1</span>
<span class="tag">步骤 #5</span>
<span>点击【新增】按钮</span>
</div>
<div class="case_step">
<span class="tag">步骤 #2</span>
<span class="tag">步骤 #6</span>
<span>输入账号:None,用户名:admin,密码:Ubains@54321,确认密码: Ubains@54321,手机号:13724387311,邮箱:1064963571@qq.com</span>
</div>
<div>
<img class="screenshot" src="imgs/20241104102637654300.png" width="aa">
<img class="screenshot" src="imgs/20241104192459695911.png" width="aa">
</div>
<div class="case_step">
<span class="tag">步骤 #3</span>
<span class="tag">步骤 #7</span>
<span>点击【确定】按钮</span>
</div>
<div>
<img class="screenshot" src="imgs/20241104102639836413.png" width="aa">
<img class="screenshot" src="imgs/20241104192501870082.png" width="aa">
</div>
<div class="info">Alert text: 账号为空</div>
<div class="case_step">
<span class="tag">步骤 #4</span>
<span class="tag">步骤 #8</span>
<span>校验提示信息: 账号为空</span>
</div>
<div class="checkpoint_pass">
......@@ -481,7 +506,7 @@ function next_error(){
<div class="folder_header">
<span class="label">套件清除</span>
<span>cases\</span>
<span class="executetime">2024-11-04 10:26:39</span>
<span class="executetime">2024-11-04 19:25:01</span>
</div>
<div class="folder_body">
<div class="info">清除浏览器</div>
......
......@@ -34,14 +34,20 @@
========= 测试开始 : 20241104_102630 =========
========= 测试开始 : 20241104_192451 =========
>>> cases\
[ suite setup ] cases\
-- 第 1 步 -- 初始化浏览器
'----------' 正在初始化浏览器 '----------'
-- 第 2 步 -- 处理SSL认证
'----------' 正在处理SSL证书警告 '----------'
'----------' SSL证书警告处理完成 '----------'
......@@ -49,34 +55,43 @@
>>> cases\账号管理\
[ suite setup ] cases\账号管理\
-- 第 3 步 -- 管理员登录系统
输入用户名:admin@ZDH
输入密码:Ubains@4321
输入验证码:csba
点击登录按钮
picture imgs/20241104192455746219.png
-- 第 4 步 -- 进入后台管理页面
进入后台
picture imgs/20241104192456359052.png
打开账号管理下拉菜单
进入用户管理模块
picture imgs/20241104192457125606.png
>>> cases\账号管理\用户管理.py
* 用户新增_001 - 2024-11-04 10:26:35
* 用户新增_001 - 2024-11-04 19:24:57
[ case execution steps ]
-- 第 1 步 -- 点击【新增】按钮
-- 第 5 步 -- 点击【新增】按钮
-- 第 2 步 -- 输入账号:None,用户名:admin,密码:Ubains@54321,确认密码: Ubains@54321,手机号:13724387311,邮箱:1064963571@qq.com
-- 第 6 步 -- 输入账号:None,用户名:admin,密码:Ubains@54321,确认密码: Ubains@54321,手机号:13724387311,邮箱:1064963571@qq.com
picture imgs/20241104102637654300.png
picture imgs/20241104192459695911.png
-- 第 3 步 -- 点击【确定】按钮
-- 第 7 步 -- 点击【确定】按钮
picture imgs/20241104102639836413.png
picture imgs/20241104192501870082.png
Alert text: 账号为空
-- 第 4 步 -- 校验提示信息: 账号为空
-- 第 8 步 -- 校验提示信息: 账号为空
** 检查点 ** 弹出提示 ----> 通过
......@@ -87,10 +102,10 @@ Alert text: 账号为空
清除浏览器
========= 测试结束 : 20241104_102642 =========
========= 测试结束 : 20241104_192504 =========
耗时 : 11.819
耗时 : 12.881
预备执行用例数量 : 1
......
此差异已折叠。
此差异已折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论