# -*- coding: UTF-8 -*- import copy import time import pytest from common.read_data.read_data import ReadData from common.ui_common.objects.tunnels import Tunnels from cases.conftest import demo_fixture from common.ui_common.objects.objects_public_operations import * data = ReadData() class TestTunnels: # 测试点:增删改查、选择颜色、新建修改后数据是否相同、name最大长度 # 24.1.3 pass # 24.1.22pass @pytest.mark.parametrize("data", data.read_data_object("tunnels.json"), ids=data.generate_id) def test_tunnels(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels.tunnels_case(data) # 测试点:校验name、Description和Endpoint # 24.1.3 pass # 24.1.22pass @pytest.mark.parametrize( "data", [ { "ids": "name输入不足四个字符时的校验,item不能校验", "Search_type": "Name", "Name": "test_quotedtest" } ] ) def test_input_verify(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels.input_verify(data) # 测试点:列设置 def test_column_settings(self, demo_fixture): tunnels = Tunnels(demo_fixture) tunnels.tunnel_column_settings_case() # 测试点:翻页 @pytest.mark.parametrize("data", data.read_data_object(r"URLs\\pages_turning.json"), ids=data.generate_id) def test_page_turning(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels._goto_subObjectPage() tunnels.objects_po.pages_turning(data) # 24.1.3 pass # 24.1.22pass # 测试点:Audit Logs审计日志(创建) # Todo 增删 # @pytest.mark.parametrize( # "data", # [ # { # "ids": "Tunnel的Audit Logs:增加和编辑", # "Search_type": "Name", # "type": " " # } # ] # ) # def test_tunnels_audit_case(self, demo_fixture, data): # tunnels = Tunnels(demo_fixture) # tunnels._verify_audit_logs(data) # 24.1.3pass # 测试点:删除引用数据 # 24.1.22del_policy中加上时间等待 @pytest.mark.parametrize( "data", [ { "ids": "Tunnel的增删改查", "Search_type": "Name", "Name": "test_quotedtest", "delete_mode": "security", "type": " ", "isDeleteGroup": "True" } ] ) def test_delete_quoted_object(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels._delete_quoted_object(data) # def test_list_check(self, demo_fixture): # tunnels = Tunnels(demo_fixture) # tunnels._list_check() @pytest.mark.parametrize( "data", [ { "ids": "Tunnel中新建IP Object", "Search_type": "Name", "type": "IP", "isDeleteGroup": "True" }, { "ids": "Tunnel中新建IP Object", "Search_type": "Name", "type": "GRE", "isDeleteGroup": "True" }, { "ids": "Tunnel中新建IP Object", "Search_type": "Name", "type": "GTP", "isDeleteGroup": "True" } ] ) def test_tunnel_new_ip(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels.create_tunnel(data) tunnels._delete(data) # tunnels.delete_created_ip_bymself(data) @pytest.mark.parametrize( "data", [ { "ids": "Tunnel中组合查询", "Search_type": "UUID", "type": "All", "isDeleteGroup": "True" }, { "ids": "Tunnel中根据IP查询", "Search_type": "Name", "type": "IP", "isDeleteGroup": "True" }, { "ids": "Tunnel中根据IP查询", "Search_type": "IP", "type": "IP", "isDeleteGroup": "True" }, ] ) def test_tunnel_query_case(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels.create_tunnel(data) tunnels._delete(data) # tunnels.delete_created_ip_bymself(data) @pytest.mark.parametrize( "data", [ { "ids": "Tunnel编辑页查询item", "Search_type": "IP", "type": "IP", "isDeleteGroup": "False" } ] ) def test_item_search_function_in_edit_page(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels.item_search_verify(data) tunnels.delete_created_ip_bymself(data) @pytest.mark.parametrize( "data", [ { "ids": "选中对象", # "//": "注释!,page_flag = 0 --列表页,page_flag =1--详情页", "page_flag": 0, # "///": "注释!selected items Type=0选中对象,selected items Type=1则选中对象组,selected items Type=2则选中对象和对象组,selected items Type=3则任意非本Vsys的对象", "selected_object_type": 0, # "////": "注释!selected_objects 要选中的条数,如selected_objects =-1,则随机条数", "selected_objects": -1, "selected_data": -1, # "/////": "注释!,detail_type = 0 --Object详情页,detail_type =1--Object Group详情页,detail_type=2--非本Vsys的Object详情页", "detail_type": 0 }, { "ids": "选中0个对象", "page_flag": 0, "selected_object_type": 0, "selected_objects": 0, "selected_data": 1, "detail_type": 0 }, { "ids": "对象详情页", "page_flag": 1, "selected_object_type": 0, "selected_objects": -1, "selected_data": -1, "detail_type": 0 }, { "ids": "非本Vsys的Object详情页", "page_flag": 1, "selected_object_type": 0, "selected_objects": -1, "selected_data": -1, "detail_type": 2 } ] ) # @pytest.mark.repeat(3) def test_clear_counter(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels._clear_counter(data) @pytest.mark.parametrize("data", data.read_data_object("tunnels.json"), ids=data.generate_id) def test_view_statistics(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels._View_statistics_case(data) @pytest.mark.parametrize( "data", [ { "ids": "modify tunnel时修改tunnel,删除endpoint b", "Search_type": "Name", "type": "IP", } ] ) def test_tunnel_modify_item(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels.modify_tunnel(data) # 24.1.3pass # 24.1.22 pass # 测试点:导出单个Tunnel # @pytest.mark.parametrize("data", # [ # { # "ids": "Tunnel现在不支持导出", # "Description": "", # "CreatType": "Tunnel", # "Search_type": "Name", # "sub_type":"not_export" # } # ]) # def test_export_objects_and_verify(self, data): # driver = download_files() # tunnels = Tunnels(driver) # tunnels._export_objects_and_verify(data) # driver.quit() # 24.1.3pass # 测试点:单选数据导出已测试 # 1.错误情况(单选取消选中目标数据、多选取消选中目标数据) # 2.正常情况(单选数据导出,多选导出部分数据,多选导出所有数据) # 3.所有数据前都有复选框(全选是否导出所有) # 24.1.22pass 修改导出按钮和导出弹窗中no按钮 # @pytest.mark.parametrize( # "data", # [ # { # "ids": "01.取消导出:单选、多选选择后取消", # "Search_type": "Name", # "Name": "test_cancel_export", # "SubType": "cancel_export", # "multi_type": " " # },{ # "ids": "02.多选:全部导出", # "Search_type": "Name", # "Name": "multi_export", # "SubType": "multi_export", # "multi_type": "all" # },{ # "ids": "01.多选:部分导出", # "Search_type": "Name", # "Name": "multi_export", # "SubType": "multi_export", # "multi_type": " " # } # ] # ) # def test_export_multi_condition_test(self, demo_fixture, data): # tunnels = Tunnels(demo_fixture) # tunnels.export_multi_condition_test(data) # # 测试点: # #Tvsys10实际上对应ui自动化测试账号PerfomanceTestVsys,Tvsys3对那个UIAutoTestVsys # @pytest.mark.parametrize( # "data", # [ # { # "ids": "1、仅可查看本vsys下的数据,其他非vsys数据不可见", # "CreatType": "Tunnel", # "SubType": "ID", # "Search_type": "Name", # "Name":"", # "vsys_operate":{"step1": "Tvsys10->create", "step2": "Tvsys3->search"} # }, # { # "ids": "2、supermode open,mvsys对下Tvsys只有查看权限", # "CreatType": "Tunnel", # "SubType": "ID", # "Search_type": "Mvsys对其下Tvsys只有查看权限", # "Name":"", # "vsys_operate":{"step1": "super_Tvsys10->create", "step2": "super_Mvsys3->search"} # }, # { # "ids": "3、Security Policy仅能引用本vsys内的数据", # "CreatType": "Tunnel", # "SubType": "ID", # "Search_type": "…………", # "Name": "测试tunnel的vsys可见性的security_policy", # "vsys_operate": {"step1": "super_Tvsys10->create", "step2": "super_Tvsys10->security_quote"}, # "delete_mode": "security" # } # ] # ) # def test_tunnels_vsys_case(self,demo_fixture, data): # tunnels = Tunnels(demo_fixture) # tunnels._vsys_case(data) @pytest.mark.parametrize("data", [ { "ids": "test_different_vsys_check", "CreatType": "Tunnel", "SubType": "", "Search_type": "Name", "type": "IP", "isDeleteGroup": "True" } ]) def test_different_vsys_check(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels._different_vsys_check(data) @pytest.mark.parametrize("data", [ { "ids": "test_audit_log_all_operation", "CreatType": "Tunnel", "SubType": "", "Search_type": "Name", "type": "IP", "isDeleteGroup": "True" } ]) def test_audit_log_all_operation(self, demo_fixture, data): tunnels = Tunnels(demo_fixture) tunnels._audit_log_all_operation(data) # @pytest.mark.parametrize("data", [ # { # "ids": "多个Object重复item校验", # "CreatType": "Tunnel", # "SubType": "", # "Search_type": "Name", # "type": "IP", # "isDeleteGroup": "True" # }, # { # "ids": "多个Object重复item校验", # "CreatType": "Tunnel", # "Model": "modify", # "SubType": "", # "Search_type": "Name", # "type": "IP", # "isDeleteGroup": "True" # }, # { # "ids": "Object内重复item校验", # "repetition_type": "1", # "CreatType": "Tunnel", # "SubType": "", # "Search_type": "Name", # "type": "IP", # "isDeleteGroup": "True" # } # ]) # def test_item_duplicate_check(self, demo_fixture, data): # tunnels = Tunnels(demo_fixture) # tunnels._item_duplicate_check(data) if __name__ == '__main__': chrome_option = webdriver.ChromeOptions() a = getwebdriver() a.get("http://192.168.45.158") a.maximize_window() a.find_element(By.XPATH, '//input[@placeholder="User name"]').send_keys("admin") a.find_element(By.XPATH, '//input[@placeholder="Password"]').send_keys("admin") a.find_element(By.XPATH, '//button[@class="MuiButtonBase-root MuiButton-root MuiLoadingButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeLarge MuiButton-containedSizeLarge MuiButton-colorPrimary MuiButton-root MuiLoadingButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeLarge MuiButton-containedSizeLarge MuiButton-colorPrimary !bg-[#4487d4] css-zeizzp"]').click() """ # 在测试文件的当前路径执行如下命令执行测试用例: pytest –cache-clear -v pytest_json.py --alluredir ./allure # 执行如下命令生成测试报告(自动打开浏览器): allure serve allure """