提交 eee8ba11 authored 作者: 彭甘宇's avatar 彭甘宇

新增区域分组和区域功能模块代码

上级 37b23909
1、整合脚本使用hytest框架,需要手动下载本地环境:pip install hytest
\ No newline at end of file
1、整合脚本使用hytest框架,需要手动下载本地环境:pip install hytest
2024-12-12
1、新增“区域类型-新增、编辑、删除”代码;
2024-12-11
1、新增“区域分组-新增、编辑、删除”代码;
2024-11-30
1、新增“用户管理-编辑、查询、删除”代码;
2、增加钉钉通知方法;
3、增加用户测试数据中的数据;
2024-11-02
1、解决框架初始化异常问题
2、新增“用户管理-新增”代码;
2024-10-24
1、调整代码使用自动化测试框架hytest
2024-09-21
1、新增登录模式模块代码
2、处理浏览器ssl认证问题
\ No newline at end of file
from lib.login import *
def suite_setup():
wd = GSTORE['wd']
open_browser()
user_login("admin@pgy", "ub@123456", "csba")
enter_system()
enter_manage()
enter_areagroup_manage()
def suite_teardown():
INFO('进行清除操作')
wd = GSTORE['wd']
wd.quit()
from lib.login import *
class AreagroupAdd001:
name = 'Areagroup_add_001'
def teststeps(self):
wd = GSTORE['wd']
STEP(1, '点击新增按钮')
areagroup_add = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[@class='company-edmit-right']//span[contains(text(),'新增')]"))
)
areagroup_add.click()
sleep(2)
STEP(2, '填写分组名称')
group_name = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@placeholder='长度1-20个字符']"))
)
group_name.clear()
group_name.send_keys("测试区域1")
STEP(3, '填写分组地址')
group_address = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@placeholder='输入地址不能大于50个字符']"))
)
group_address.clear()
group_address.send_keys("顺恒利大厦")
STEP(4, '填写分组备注')
group_remark = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='请输入备注']"))
)
group_remark.clear()
group_remark.send_keys("测试分组备注")
STEP(6, '点击确认')
commit = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[@class='dialog-footer']//span[contains(text(),'确 定')]"))
)
commit.click()
STEP(7, '验证是否新增成功')
get_menu = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '.el-message__content'))
)
get_menu1 = get_menu.text
CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
sleep(2)
\ No newline at end of file
from lib.login import *
class UserAdd001:
name = 'user_add_001'
def teststeps(self):
wd = GSTORE['wd']
STEP(1, '点击新增按钮')
user_add = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[@class='company-edmit-right']//span[contains(text(),'新增')]"))
)
user_add.click()
sleep(2)
STEP(2, '填写登录名')
account_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@placeholder='登录名以字母开头,长度在5-18之间,只能包含字母、数字和下划线、@']"))
)
account_input.clear()
account_input.send_keys("admin@test1")
STEP(3, '填写用户名称')
account_name_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请输入用户名称']"))
)
account_name_input.clear()
account_name_input.send_keys("admin@test1")
STEP(4, '填写新密码')
passwd_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='必须包含字母(不区分大小写)、数字和特殊字符,至少8个字符']"))
)
passwd_input.clear()
passwd_input.send_keys("ub@123456")
STEP(5, '填写确认密码')
sepasswd_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='请确认密码']"))
)
sepasswd_input.clear()
sepasswd_input.send_keys("ub@123456")
STEP(6, '点击确认')
commit = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[@aria-label='新增']//span[contains(text(),'确 定')]"))
)
commit.click()
STEP(7, '验证是否新增成功')
get_menu = WebDriverWait(wd, 10).until(
EC.visibility_of_element_located((By.XPATH, "//p[@class='el-message__content']"))
)
get_menu1 = get_menu.text
INFO(get_menu1)
CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
sleep(2)
# class UserAdd002:
# name = 'user_add_002'
# def teststeps(self):
# wd = GSTORE['wd']
#
# STEP(1, '点击新增按钮')
# user_add = WebDriverWait(wd, 10).until(
# EC.element_to_be_clickable((By.XPATH, "//div[@class='company-edmit-right']//span[contains(text(),'新增')]"))
# )
# user_add.click()
# sleep(2)
#
# STEP(2, '填写登录名')
# account_input = WebDriverWait(wd, 10).until(
# EC.presence_of_element_located((By.XPATH, "//input[@placeholder='登录名以字母开头,长度在5-18之间,只能包含字母、数字和下划线、@']"))
# )
# account_input.clear()
# account_input.send_keys("admin@test1")
#
# STEP(3, '填写用户名称')
# account_name_input = WebDriverWait(wd, 10).until(
# EC.presence_of_element_located((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请输入用户名称']"))
# )
# account_name_input.clear()
# account_name_input.send_keys("测试用户2")
#
# STEP(4, '填写新密码')
# passwd_input = WebDriverWait(wd, 10).until(
# EC.presence_of_element_located(
# (By.XPATH, "//input[@placeholder='必须包含字母(不区分大小写)、数字和特殊字符,至少8个字符']"))
# )
# passwd_input.clear()
# passwd_input.send_keys("ub@123456")
#
# STEP(5, '填写确认密码')
# sepasswd_input = WebDriverWait(wd, 10).until(
# EC.presence_of_element_located(
# (By.XPATH, "//input[@placeholder='请确认密码']"))
# )
# sepasswd_input.clear()
# sepasswd_input.send_keys("ub@123456")
#
# STEP(6, '点击确认')
# commit = WebDriverWait(wd, 10).until(
# EC.element_to_be_clickable((By.XPATH, "//div[@aria-label='新增']//span[contains(text(),'确 定')]"))
# )
# commit.click()
#
# STEP(7, '验证是否正常提示')
# get_menu = WebDriverWait(wd, 10).until(
# EC.presence_of_element_located((By.CSS_SELECTOR, '.el-message__content'))
# )
# get_menu1 = get_menu.text
# # CHECK_POINT('检查是否出现错误提示弹窗', get_menu1 == "登录名已存在,请重新输入")
# CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
# sleep(2)
from lib.login import *
class Userquery001:
name = 'user_query_001'
def teststeps(self):
wd = GSTORE['wd']
STEP(1, '点击搜索框')
user_query = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='请输入用户名称']"))
)
user_query.click()
sleep(2)
STEP(2, '填写登录名')
account_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@placeholder='请输入用户名称']"))
)
account_input.clear()
account_input.send_keys("admin@test1")
STEP(3, '校验是否成功检索用户')
get_user = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//div[normalize-space()='admin@test1']"))
)
get_username = get_user.text
CHECK_POINT('校验是否成功检索用户', get_username == "admin@test1")
sleep(2)
# 调用钉钉输出测试报告
# get_reportfile_send_dingding("123213_测试报告", "http://192.168.1.251")
\ No newline at end of file
from lib.login import *
class UserModify001:
name = 'user_modify_001'
def teststeps(self):
wd = GSTORE['wd']
STEP(1, '点击搜索框')
user_query = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='请输入用户名称']"))
)
user_query.click()
sleep(2)
STEP(2, '填写登录名')
account_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@placeholder='请输入用户名称']"))
)
account_input.clear()
account_input.send_keys("admin@test1")
STEP(3, '勾选用户')
select_click= WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//tbody//tr//td//div//label//span//span"))
)
select_click.click()
sleep(2)
STEP(4, '点击编辑按钮')
user_update = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'company-edmit-right')]//span[contains(text(),'编辑')]"))
)
user_update.click()
sleep(2)
STEP(5, '填写用户名称')
account_name_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//div[@class='el-input el-input--suffix']//input[@placeholder='请输入用户名称']"))
)
account_name_input.clear()
account_name_input.send_keys("admin@update")
STEP(6, '勾选修改密码按钮')
user_passwd_click = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[contains(@class,'dialog-input')]//span[contains(@class,'el-checkbox__inner')]"))
)
user_passwd_click.click()
sleep(2)
STEP(6, '填写当前用户密码')
current_passwd = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[contains(@placeholder,'请输当前登录用户的密码')]"))
)
current_passwd.clear()
current_passwd.send_keys("ub@123456")
STEP(7, '填写新密码')
newpasswd = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[contains(@placeholder,'必须包含字母(不区分大小写)、数字和特殊字符,至少8个字符')]"))
)
newpasswd.clear()
newpasswd.send_keys("ub@12345678")
STEP(8, '填写确认密码')
verify_passwd = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='请确认密码']"))
)
verify_passwd.clear()
verify_passwd.send_keys("ub@12345678")
STEP(9, '填写用户工号')
sepasswd_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='请输入工号']"))
)
sepasswd_input.clear()
sepasswd_input.send_keys("123456")
STEP(9, '填写手机号')
phone = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='请输入手机号码']"))
)
phone.clear()
phone.send_keys("13169131242")
STEP(10, '填写邮箱')
sepasswd_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='请输入邮箱']"))
)
sepasswd_input.clear()
sepasswd_input.send_keys("12341@qq.com")
STEP(11, '填写备注')
user_remark = WebDriverWait(wd, 10).until(
EC.presence_of_element_located(
(By.XPATH, "//input[@placeholder='备注']"))
)
user_remark.clear()
user_remark.send_keys("测试用户")
STEP(12, '点击确认')
commit = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//div[contains(@aria-label,'编辑')]//span[contains(text(),'确 定')]"))
)
commit.click()
STEP(13, '验证是否编辑成功')
get_menu = WebDriverWait(wd, 10).until(
EC.visibility_of_element_located((By.XPATH, "//p[@class='el-message__content']"))
)
get_menu1 = get_menu.text
CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
sleep(2)
\ No newline at end of file
from lib.login import *
class Userdelete001:
name = 'user_delete_001'
def teststeps(self):
wd = GSTORE['wd']
STEP(1, '点击搜索框')
user_query = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='请输入用户名称']"))
)
user_query.click()
sleep(2)
STEP(2, '填写登录名')
account_input = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//input[@placeholder='请输入用户名称']"))
)
account_input.clear()
account_input.send_keys("admin@test1")
STEP(3, '勾选用户')
select_click= WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.XPATH, "//tbody//tr//td//div//label//span//span"))
)
select_click.click()
sleep(2)
STEP(4, '点击删除按钮')
user_update = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'删除')]"))
)
user_update.click()
sleep(2)
STEP(5, '点击确认')
commit = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//button[contains(@class,'el-button el-button--default el-button--small el-button--primary')]//span[contains(text(),'确 定')]"))
)
commit.click()
STEP(6, '验证是否删除成功')
get_menu = WebDriverWait(wd, 10).until(
EC.visibility_of_element_located((By.XPATH, "//p[@class='el-message__content']"))
)
get_menu1 = get_menu.text
CHECK_POINT('检查是否出现成功提示弹窗', get_menu1 == "操作成功!")
sleep(2)
# 本地启动http微服务
# python - m http.server 80 - -directory log
# 输出报告到钉钉
get_reportfile_send_dingding("用户管理模块_测试报告", "http://192.168.1.251")
\ No newline at end of file
from lib.login import *
def suite_setup():
wd = GSTORE['wd']
user_login("admin@pgy", "ub@123456", "csba")
enter_system()
enter_manage()
enter_user_manage()
# def suite_teardown():
# INFO('进行清除操作')
# wd = GSTORE['wd']
# wd.quit()
from lib.login import *
# def suite_setup():
# wd = GSTORE['wd']
def suite_teardown():
INFO('进行清除操作')
wd = GSTORE['wd']
wd.quit()
from lib.login import *
class user_login_001:
name = 'login_test_01'
def teststeps(self):
wd = GSTORE['wd']
STEP(1, '用户登录')
user_login("admin@pgy", "ub@123456", "csba")
# run_login_tests()
STEP(2, '验证是否登录成功')
get_menu = WebDriverWait(wd, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '.el-message__content'))
)
get_menu1 = get_menu.text
CHECK_POINT('检查是否出现弹窗', get_menu1 == "操作成功!")
def suite_teardown():
wd.quit()
# class user_login_002:
# name = 'login_test_02'
#
# def teststeps(self):
# STEP(1, '打开网页')
#
# wd = GSTORE['wd']
#
# STEP(2, '用户登录')
# user_login("admin@pgy", "ub@123456", "csba")
# # run_login_tests()
#
# STEP(3, '验证是否登录成功')
# get_menu = WebDriverWait(wd, 10).until(
# EC.presence_of_element_located((By.CSS_SELECTOR, '.el-message__content'))
# )
# get_menu1 = get_menu.text
# CHECK_POINT('检查是否出现弹窗', get_menu1 == "操作成功!")
#
# STEP(4, '清除数据')
#
# def suite_teardown():
# INFO('进行清除操作')
# wd.quit()
......@@ -32,7 +32,7 @@ def open_browser():
wd = webdriver.Edge(options=edge_options)
GSTORE['wd'] = wd
# wd.get('https://rms.ubainsyun.com/#/login')
wd.get('https://192.168.1.118:8443/#/login')
wd.get('https://192.168.5.218:8443/#/login')
wd.maximize_window()
wd.implicitly_wait(10)
......@@ -151,14 +151,44 @@ def enter_areagroup_manage():
logging.info('点击区域分组按钮')
try:
enter_user_mag = WebDriverWait(wd, 10).until(
enter_areagroup_mag = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//li[contains(text(),'区域分组')]"))
)
enter_user_mag.click()
enter_areagroup_mag.click()
logging.info('打开区域分组页面')
except (TimeoutException, ElementNotInteractableException) as error:
logging.error(f"Error clicking manage button: {error}")
def enter_areatype_manage():
wd = GSTORE['wd']
if wd is None:
raise ValueError("WebDriver is not initialized")
logging.info('点击区域类型按钮')
try:
enter_areatype_mag = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//li[contains(text(),'区域类型')]"))
)
enter_areatype_mag.click()
logging.info('打开区域类型页面')
except (TimeoutException, ElementNotInteractableException) as error:
logging.error(f"Error clicking manage button: {error}")
def enter_areafuntion_manage():
wd = GSTORE['wd']
if wd is None:
raise ValueError("WebDriver is not initialized")
logging.info('点击区域功能按钮')
try:
enter_areafuntion_mag = WebDriverWait(wd, 10).until(
EC.element_to_be_clickable((By.XPATH, "//li[contains(text(),'区域功能')]"))
)
enter_areafuntion_mag.click()
logging.info('打开区域功能页面')
except (TimeoutException, ElementNotInteractableException) as error:
logging.error(f"Error clicking manage button: {error}")
def dingding_send_message(test_report_url, title, text, mobile):
"""
发送钉钉机器人消息
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论