添加赛区脚本
- test_后台_双创_基础设置_赛区管理_添加赛区_case_v7.py
- 导入各个网页对象
- 改造to_division_manager
导入各个网页对象
- 导入各个网页对象:
from page.后台_主页_page_v1 import BgHomePage
from page.后台_双创_基础设置_添加赛区_page_v1 import BgAddDivisionPage
from page.后台_双创_基础设置_赛区管理_page_v1 import BgDivisionManagerPage
# 改造to_division_manager
@pytest.fixture(scope='class', autouse=True)
def to_division_manager(login_and_logout):
driver = login_and_logout
homepage=BgHomePage(driver)
# 展开基础设置
homepage.open_basic_setting()
# 等待基础设置被打开
homepage.wait_basic_setting_opened()
# 进入赛区管理
homepage.to_division_manager()
# 切换到赛区管理子网页
homepage.switch_to_division_manager_frame()
# 等待加载完毕
BgDivisionManagerPage(driver).wait_for_loaded()
yield driver
driver.switch_to.default_content()
# 改造test_add_division
@pytest.mark.parametrize("division_name,message",rd.get_data("测试用例_AISE_后台_双创_基础设置_赛区管理_添加赛区.csv"))
def test_add_division(self,to_division_manager,division_name,message):
driver = to_division_manager
divisionmanager = BgDivisionManagerPage(driver)
if message=="赛区信息保存成功": # 有效
# 用赛区名称查询
divisionmanager.search(division_name)
sleep(2)
# 判断查询结果里是否存在等于目标赛区名称的记录
if divisionmanager.is_division_exist(division_name):
# 删除后确定
divisionmanager.delete_and_confirm(division_name)
sleep(3)
# 添加赛区
divisionmanager.to_add_division()
# 等待加载完毕
divisionmanager.wait_for_loaded()
# 切换到添加赛区子网页
divisionmanager.switch_to_add_page()
adddivision = BgAddDivisionPage(driver)
if message=="不能为空":
# 获得浮动提示
assert adddivision.get_tooltip()=="该输入项为必输项"
# 输入赛区名称
adddivision.input_division_name(division_name)
driver.switch_to.default_content()
# 滚动条滑动到底部
homepage=BgHomePage(driver)
homepage.to_bottom()
# 切换到赛区管理子网页
homepage.switch_to_division_manager_frame()
# 切换到添加赛区子网页
BgDivisionManagerPage(driver).switch_to_add_page()
sleep(2)
# 提交
BgAddDivisionPage(driver).submit()
sleep(1)
driver.switch_to.parent_frame()
# 检查提示信息是否出现
divisionmanager=BgDivisionManagerPage(driver)
assert divisionmanager.is_message_exist(message)
# 等待提示信息消失
divisionmanager.wait_message_dispear(message)
if message!="赛区信息保存成功":
# 切换到添加赛区子网页
divisionmanager.switch_to_add_page()
BgAddDivisionPage(driver).cancel()# 取消
driver.switch_to.default_content()
# 滚动条滑动到顶部
homepage=BgHomePage(driver)
homepage.to_top()
# 切换到赛区管理子网页
homepage.switch_to_division_manager_frame()
divisionmanager=BgDivisionManagerPage(driver)
# 等待加载完毕
divisionmanager.wait_for_loaded()
if message=="赛区信息保存成功": # 有效
# 用赛区名称查询
divisionmanager.search(division_name)
sleep(2)
# 检查查询结果里存在等于目标赛区名称的记录
assert divisionmanager.is_division_exist(division_name)
sleep(3)
运行,查看结果
========= test session starts =====================
platform win32 -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
sensitiveurl: .*
rootdir: D:\PycharmProjects\aiseProject2\testcasecode
collected 10 items
test_后台_双创_基础设置_赛区管理_添加赛区_case_v7.py ..........
=========== 10 passed in 637.78s (0:10:37) ============
Process finished with exit code 0
作者:暄总-tester