Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
U
ubains-module-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
郑晓兵
ubains-module-test
Commits
e4737c3c
提交
e4737c3c
authored
2月 07, 2025
作者:
彭甘宇
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(测试脚本):优化区域管理相关测试用例- 调整元素定位方式
- 优化测试步骤描述,增加细节 - 修复部分测试用例中的错误 - 删除未使用的代码片段
上级
3ebce33c
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
135 行增加
和
176 行删除
+135
-176
03删除区域分组.py
运维集控/项目测试/运维标准版/cases/03区域分组/03删除区域分组.py
+44
-44
03删除区域功能.py
运维集控/项目测试/运维标准版/cases/05区域功能/03删除区域功能.py
+56
-56
01新增区域.py
运维集控/项目测试/运维标准版/cases/06区域管理/01新增区域.py
+1
-2
02编辑区域.py
运维集控/项目测试/运维标准版/cases/06区域管理/02编辑区域.py
+15
-18
03删除区域.py
运维集控/项目测试/运维标准版/cases/06区域管理/03删除区域.py
+13
-51
__st__.py
运维集控/项目测试/运维标准版/cases/06区域管理/__st__.py
+3
-3
base.py
运维集控/项目测试/运维标准版/lib/base.py
+1
-0
定时任务执行.py
运维集控/项目测试/运维标准版/定时任务执行.py
+2
-2
没有找到文件。
运维集控/项目测试/运维标准版/cases/03区域分组/03删除区域分组.py
浏览文件 @
e4737c3c
#
import sys
#
import os
#
#
from hytest.common import SELENIUM_LOG_SCREEN
#
#
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..')))
#
from 运维集控.项目测试.运维标准版.lib.base import *
#
#
class AreagroupDel01:
#
name = '删除分组-001-单个删除'
#
def teststeps(self):
#
wd = GSTORE['wd']
#
#
STEP(1, '勾选分组')
#
areagroup_select = WebDriverWait(wd, 10).until(
#
EC.presence_of_element_located((By.XPATH, "(//span[@class='el-checkbox__inner'])[2]"))
#
)
#
areagroup_select.click()
#
sleep(1)
#
#
STEP(2, '点击“删除”按钮')
#
areagroup_modify = WebDriverWait(wd, 10).until(
#
EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'删除')]"))
#
)
#
areagroup_modify.click()
#
sleep(1)
#
#
STEP(3, '点击确认')
#
commit = WebDriverWait(wd, 10).until(
#
EC.element_to_be_clickable((By.XPATH, "(//span[contains(text(),'确 定')])[3]"))
#
)
#
commit.click()
#
#
STEP(6, '验证是否修改成功')
#
get_menu = WebDriverWait(wd, 10).until(
#
EC.visibility_of_element_located((By.CSS_SELECTOR, '.el-message__content'))
#
)
#
get_menu1 = get_menu.text
#
CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
#
#
# 截图并保存
#
SELENIUM_LOG_SCREEN(wd, "50%")
#
wd.refresh()
#
import
sys
import
os
from
hytest.common
import
SELENIUM_LOG_SCREEN
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'..'
,
'..'
,
'..'
)))
from
运维集控
.
项目测试
.
运维标准版
.
lib
.
base
import
*
class
AreagroupDel01
:
name
=
'删除分组-001-单个删除'
def
teststeps
(
self
):
wd
=
GSTORE
[
'wd'
]
STEP
(
1
,
'勾选分组'
)
areagroup_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
presence_of_element_located
((
By
.
XPATH
,
"(//span[@class='el-checkbox__inner'])[2]"
))
)
areagroup_select
.
click
()
sleep
(
1
)
STEP
(
2
,
'点击“删除”按钮'
)
areagroup_modify
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
((
By
.
XPATH
,
"//span[contains(text(),'删除')]"
))
)
areagroup_modify
.
click
()
sleep
(
1
)
STEP
(
3
,
'点击确认'
)
commit
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
((
By
.
XPATH
,
"(//span[contains(text(),'确 定')])[3]"
))
)
commit
.
click
()
STEP
(
6
,
'验证是否修改成功'
)
get_menu
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
visibility_of_element_located
((
By
.
CSS_SELECTOR
,
'.el-message__content'
))
)
get_menu1
=
get_menu
.
text
CHECK_POINT
(
'检查是否出现成功提示弹窗'
,
get_menu1
==
"操作成功!"
)
# 截图并保存
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
)
wd
.
refresh
()
# class AreagroupDel02:
# name = '删除分组-002-多个删除'
# def teststeps(self):
...
...
运维集控/项目测试/运维标准版/cases/05区域功能/03删除区域功能.py
浏览文件 @
e4737c3c
#
import sys
#
import os
#
#
from hytest.common import SELENIUM_LOG_SCREEN
#
#
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..')))
#
from 运维集控.项目测试.运维标准版.lib.base import *
#
#
class areafuntionDel001:
#
name = '删除区域功能-001-搜索删除单个功能'
#
def teststeps(self):
#
wd = GSTORE['wd']
#
#
STEP(1, '搜索对应的区域功能')
#
areafuntion_search= WebDriverWait(wd, 10).until(
#
EC.element_to_be_clickable(
#
(By.XPATH, "//input[@placeholder='请输入功能名称']"))
#
)
#
areafuntion_search.clear()
#
areafuntion_search.send_keys("修改-测试功能1")
#
#
STEP(2, '勾选区域功能')
#
areafuntion_select = WebDriverWait(wd, 10).until(
#
EC.element_to_be_clickable(
#
(By.XPATH, "(//span[@class='el-checkbox__inner'])[2]"))
#
)
#
areafuntion_select.click()
#
#
STEP(3, '点击删除按钮')
#
areafuntion_mod = WebDriverWait(wd, 10).until(
#
EC.element_to_be_clickable(
#
(By.XPATH, "//span[contains(text(),'删除')]"))
#
)
#
areafuntion_mod.click()
#
sleep(1)
#
#
STEP(4, '点击确认')
#
commit = WebDriverWait(wd, 10).until(
#
EC.element_to_be_clickable(
#
(By.XPATH, "(//span[contains(text(),'确 定')])[3]"))
#
)
#
commit.click()
#
#
STEP(5, '验证是否修改成功')
#
get_menu = WebDriverWait(wd, 10).until(
#
EC.visibility_of_element_located(
#
(By.CSS_SELECTOR, '.el-message__content'))
#
)
#
get_menu1 = get_menu.text
#
CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
#
#
# 截图并保存
#
SELENIUM_LOG_SCREEN(wd, "50%")
#
sleep(1)
#
wd.refresh()
#
import
sys
import
os
from
hytest.common
import
SELENIUM_LOG_SCREEN
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'..'
,
'..'
,
'..'
)))
from
运维集控
.
项目测试
.
运维标准版
.
lib
.
base
import
*
class
areafuntionDel001
:
name
=
'删除区域功能-001-搜索删除单个功能'
def
teststeps
(
self
):
wd
=
GSTORE
[
'wd'
]
STEP
(
1
,
'搜索对应的区域功能'
)
areafuntion_search
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//input[@placeholder='请输入功能名称']"
))
)
areafuntion_search
.
clear
()
areafuntion_search
.
send_keys
(
"修改-测试功能1"
)
STEP
(
2
,
'勾选区域功能'
)
areafuntion_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"(//span[@class='el-checkbox__inner'])[2]"
))
)
areafuntion_select
.
click
()
STEP
(
3
,
'点击删除按钮'
)
areafuntion_mod
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//span[contains(text(),'删除')]"
))
)
areafuntion_mod
.
click
()
sleep
(
1
)
STEP
(
4
,
'点击确认'
)
commit
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"(//span[contains(text(),'确 定')])[3]"
))
)
commit
.
click
()
STEP
(
5
,
'验证是否修改成功'
)
get_menu
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
visibility_of_element_located
(
(
By
.
CSS_SELECTOR
,
'.el-message__content'
))
)
get_menu1
=
get_menu
.
text
CHECK_POINT
(
'检查是否出现成功提示弹窗'
,
get_menu1
==
"操作成功!"
)
# 截图并保存
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
)
sleep
(
1
)
wd
.
refresh
()
# class areafuntionDel002:
# name = '删除区域功能-001-全选删除全部功能'
# def teststeps(self):
...
...
运维集控/项目测试/运维标准版/cases/06区域管理/01新增区域.py
浏览文件 @
e4737c3c
...
...
@@ -56,8 +56,7 @@ class AreafuntionAdd:
#默认选择第一个区域类型
areatype_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
presence_of_element_located
(
(
By
.
XPATH
,
"//div[@x-placement='bottom-start']//ul[@class='el-scrollbar__view el-select-dropdown__list']"
))
(
By
.
XPATH
,
"//div[@x-placement='bottom-start']//ul[@class='el-scrollbar__view el-select-dropdown__list']"
))
)
sleep
(
1
)
areatype_select
.
click
()
...
...
运维集控/项目测试/运维标准版/cases/06区域管理/02编辑区域.py
浏览文件 @
e4737c3c
...
...
@@ -11,21 +11,22 @@ class areafuntionMod01:
def
teststeps
(
self
):
wd
=
GSTORE
[
'wd'
]
STEP
(
1
,
'搜索对应的区域名称'
)
STEP
(
1
,
'搜索对应的区域名称
:测试区域0
'
)
areaname_search
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//div[@class='company-search el-input el-input--suffix']//input[@placeholder='请输入区域名称']"
))
)
areaname_search
.
clear
()
areaname_search
.
send_keys
(
"测试区域0"
)
areaname_search
.
send_keys
(
Keys
.
RETURN
)
STEP
(
2
,
'勾选区域'
)
area_
select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"
(//span[contains(@class,'el-checkbox__input')])[2
]"
))
STEP
(
2
,
'
点击
勾选区域'
)
area_
click
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
presence_of_element_located
(
(
By
.
XPATH
,
"
//th[contains(@class,'is-leaf el-table__cell')]//span[contains(@class,'el-checkbox__inner')
]"
))
)
area_select
.
click
(
)
sleep
(
2
)
sleep
(
1
)
area_click
.
click
(
)
STEP
(
3
,
'点击编辑按钮'
)
area_mod
=
WebDriverWait
(
wd
,
10
)
.
until
(
...
...
@@ -33,17 +34,11 @@ class areafuntionMod01:
(
By
.
XPATH
,
"//span[contains(text(),'编辑')]"
))
)
area_mod
.
click
()
sleep
(
1
)
STEP
(
4
,
'修改区域分组'
)
areagroup_clear
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
presence_of_element_located
(
(
By
.
XPATH
,
"//div[@class='dialog_input']//i[@class='el-select__caret el-input__icon el-icon-arrow-up']"
))
)
areagroup_clear
.
click
()
areagroup_input
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
presence_of_element_located
(
(
By
.
XPATH
,
"//div[
@class='dialog_input']//input[@placeholder='请选择分组'
]"
))
(
By
.
XPATH
,
"//div[
contains(@class,'dialog_input')]//input[contains(@placeholder,'请选择分组')
]"
))
)
areagroup_input
.
clear
()
areagroup_input
.
send_keys
(
"广州分组1"
)
...
...
@@ -87,11 +82,12 @@ class areafuntionMod02:
)
areaname_search
.
clear
()
areaname_search
.
send_keys
(
"测试区域0"
)
areaname_search
.
send_keys
(
Keys
.
RETURN
)
STEP
(
2
,
'勾选区域'
)
area_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"
(//span[contains(@class,'el-checkbox__inner')])[2
]"
))
(
By
.
XPATH
,
"
//th[contains(@class,'is-leaf el-table__cell')]//span[contains(@class,'el-checkbox__inner')
]"
))
)
area_select
.
click
()
...
...
@@ -108,13 +104,13 @@ class areafuntionMod02:
EC
.
presence_of_element_located
(
(
By
.
XPATH
,
"//div[@class='dialog_input']//input[@placeholder='请选择区域类型']"
))
)
areatype_input
.
cl
ear
()
areatype_input
.
cl
ick
()
areatype_input
.
send_keys
(
"大会议室"
)
# 选择类型,并点击第一个
areatype_modify
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
presence_of_element_located
(
(
By
.
XPATH
,
"//
li[@class='el-select-dropdown__item hover
']"
))
By
.
XPATH
,
"//
div[@x-placement='bottom-start']//ul[@class='el-scrollbar__view el-select-dropdown__list
']"
))
)
areatype_modify
.
click
()
...
...
@@ -150,11 +146,12 @@ class areafuntionMod03:
)
areaname_search
.
clear
()
areaname_search
.
send_keys
(
"测试区域0"
)
areaname_search
.
send_keys
(
Keys
.
RETURN
)
STEP
(
2
,
'勾选区域'
)
area_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"
(//span[contains(@class,'el-checkbox__inner')])[2
]"
))
(
By
.
XPATH
,
"
//th[contains(@class,'is-leaf el-table__cell')]//span[contains(@class,'el-checkbox__inner')
]"
))
)
area_select
.
click
()
...
...
运维集控/项目测试/运维标准版/cases/06区域管理/03删除区域.py
浏览文件 @
e4737c3c
...
...
@@ -6,38 +6,39 @@ from hytest.common import SELENIUM_LOG_SCREEN
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'..'
,
'..'
,
'..'
)))
from
运维集控
.
项目测试
.
运维标准版
.
lib
.
base
import
*
class
area
funtion
Del001
:
class
areaDel001
:
name
=
'删除区域-001-搜索删除单个区域'
def
teststeps
(
self
):
wd
=
GSTORE
[
'wd'
]
STEP
(
1
,
'搜索对应的区域'
)
area
funtion
_search
=
WebDriverWait
(
wd
,
10
)
.
until
(
area
name
_search
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//div[
contains(@class,'company-search el-input el-input--suffix')]//input[contains(@placeholder,'请输入区域名称')
]"
))
(
By
.
XPATH
,
"//div[
@class='company-search el-input el-input--suffix']//input[@placeholder='请输入区域名称'
]"
))
)
areafuntion_search
.
clear
()
areafuntion_search
.
send_keys
(
"测试区域100"
)
areaname_search
.
clear
()
areaname_search
.
send_keys
(
"测试区域100"
)
areaname_search
.
send_keys
(
Keys
.
ENTER
)
STEP
(
2
,
'勾选区域'
)
area
funtion
_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
area_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"
(//span[contains(@class,'el-checkbox__inner')])[2
]"
))
(
By
.
XPATH
,
"
//th[contains(@class,'is-leaf el-table__cell')]//span[contains(@class,'el-checkbox__inner')
]"
))
)
area
funtion
_select
.
click
()
area_select
.
click
()
STEP
(
3
,
'点击删除按钮'
)
area
funtion
_mod
=
WebDriverWait
(
wd
,
10
)
.
until
(
area_mod
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//span[contains(text(),'删除')]"
))
)
area
funtion
_mod
.
click
()
area_mod
.
click
()
sleep
(
1
)
STEP
(
4
,
'点击确认'
)
commit
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"
(//span[contains(text(),'确 定')])[3
]"
))
(
By
.
XPATH
,
"
//button[@class='el-button el-button--default el-button--small el-button--primary ']//span[contains(text(),'确 定')
]"
))
)
commit
.
click
()
...
...
@@ -47,46 +48,7 @@ class areafuntionDel001:
(
By
.
CSS_SELECTOR
,
'.el-message__content'
))
)
get_menu1
=
get_menu
.
text
CHECK_POINT
(
'检查是否出现成功提示弹窗'
,
get_menu1
==
"操作成功!"
)
# 截图并保存
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
)
sleep
(
1
)
wd
.
refresh
()
class
areafuntionDel002
:
name
=
'删除区域功能-002-批量删除'
def
teststeps
(
self
):
wd
=
GSTORE
[
'wd'
]
STEP
(
1
,
'勾选全部区域功能'
)
areafuntion_select
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//th[contains(@class,'is-leaf el-table__cell')]//span[contains(@class,'el-checkbox__inner')]"
))
)
areafuntion_select
.
click
()
STEP
(
2
,
'点击删除按钮'
)
areafuntion_mod
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"//span[contains(text(),'删除')]"
))
)
areafuntion_mod
.
click
()
sleep
(
1
)
STEP
(
3
,
'点击确认'
)
commit
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
element_to_be_clickable
(
(
By
.
XPATH
,
"(//span[contains(text(),'确 定')])[3]"
))
)
commit
.
click
()
STEP
(
4
,
'验证是否修改成功'
)
get_menu
=
WebDriverWait
(
wd
,
10
)
.
until
(
EC
.
visibility_of_element_located
(
(
By
.
CSS_SELECTOR
,
'.el-message__content'
))
)
get_menu1
=
get_menu
.
text
print
(
get_menu1
)
CHECK_POINT
(
'检查是否出现成功提示弹窗'
,
get_menu1
==
"操作成功!"
)
# 截图并保存
...
...
运维集控/项目测试/运维标准版/cases/06区域管理/__st__.py
浏览文件 @
e4737c3c
...
...
@@ -5,9 +5,9 @@ from 运维集控.项目测试.运维标准版.lib.base import *
def
suite_setup
():
wd
=
GSTORE
[
'wd'
]
user_login
(
"admin@pgy"
,
"ub@123456"
,
"csba"
)
enter_system
()
enter_manage
()
#
user_login("admin@pgy", "ub@123456", "csba")
#
enter_system()
#
enter_manage()
enter_area_manage
()
# def suite_teardown():
...
...
运维集控/项目测试/运维标准版/lib/base.py
浏览文件 @
e4737c3c
...
...
@@ -23,6 +23,7 @@ from selenium.webdriver.edge.options import Options
from
selenium.webdriver.support.wait
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions
as
EC
from
selenium.common
import
TimeoutException
,
ElementNotInteractableException
from
selenium.webdriver.common.keys
import
Keys
from
time
import
sleep
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
'
%(asctime)
s -
%(levelname)
s -
%(message)
s'
)
...
...
运维集控/项目测试/运维标准版/定时任务执行.py
浏览文件 @
e4737c3c
...
...
@@ -68,10 +68,10 @@ start_workers(3)
# 定义每天定时执行的任务
# 每天早上07:50执行后台系统设置功能测试
#
schedule.every().day.at("07:50").do(run_task, run_automation_test, report_title="运维系统测试报告", report_url_prefix="http://nat.ubainsyun.com:31135", ding_type="标准版巡检")
schedule
.
every
()
.
day
.
at
(
"07:50"
)
.
do
(
run_task
,
run_automation_test
,
report_title
=
"运维系统测试报告"
,
report_url_prefix
=
"http://nat.ubainsyun.com:31135"
,
ding_type
=
"标准版巡检"
)
# 调试使用
schedule
.
every
()
.
day
.
at
(
"09:59"
)
.
do
(
run_task
,
run_automation_test
,
report_title
=
"运维系统脚本调试"
,
report_url_prefix
=
"http://nat.ubainsyun.com:31135"
,
ding_type
=
"标准版巡检"
)
#
schedule.every().day.at("09:59").do(run_task, run_automation_test, report_title="运维系统脚本调试", report_url_prefix="http://nat.ubainsyun.com:31135", ding_type="标准版巡检")
try
:
# 无限循环,持续检查并执行计划任务
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论