summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryouzhijiang <[email protected]>2024-11-27 19:27:37 +0800
committeryouzhijiang <[email protected]>2024-11-27 19:27:37 +0800
commitde4ef3e4c5229ffd9007ca43b8cb5d838b6d6b0a (patch)
treeb3b4c3af86279e22682f31cc0d977c447ca61a56
parent3a1440a42ee4438fb5d431959f22063f641d4049 (diff)
object逻辑调整
-rw-r--r--support/ui_utils/create_objects_example.py54
-rw-r--r--support/ui_utils/delete_objects_example.py33
-rw-r--r--support/ui_utils/edit_objects_example.py35
-rw-r--r--support/ui_utils/element_position/map_element_position_library.py60
-rw-r--r--support/ui_utils/element_position/object_element_position.py8
-rw-r--r--support/ui_utils/objects/create_objects_example.py93
-rw-r--r--support/ui_utils/objects/delete_objects_example.py18
-rw-r--r--support/ui_utils/objects/edit_objects_example.py239
-rw-r--r--support/ui_utils/ui_client.py3
-rw-r--r--tests/object/test_temp/create_application_temp.py127
-rw-r--r--tests/object/test_temp/create_flag_temp.py24
-rw-r--r--tests/object/test_temp/create_tunnel_temp.py120
12 files changed, 499 insertions, 315 deletions
diff --git a/support/ui_utils/create_objects_example.py b/support/ui_utils/create_objects_example.py
deleted file mode 100644
index bd10c54b3..000000000
--- a/support/ui_utils/create_objects_example.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# -*- coding: UTF-8 -*-
-import os
-import sys
-sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
-from support.general_ui_utils.object.create_objects_temp import CreateObjects
-from support.general_ui_utils.object.search_objects import SearchObjects
-from support.ui_utils.element_position.map_element_position_library import *
-from datetime import datetime
-
-class CreateObjectsExample:
- def create_objects(self, object_configuration, driver):
- try:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Begin to run ui test case", flush=True)
-
- result = ""
- object_uuids_list = []
- object_uuids_temp_dict = {}
-
- for object in object_configuration["or_conditions"]:
- #获取当前所需的element
- if "sub_type" in object.keys():
- object_type = object["sub_type"]
- else:
- object_type = object["type"]
- element_position_library = get_element_position(object_type)
- #执行创建操作
- create_objects = CreateObjects(driver)
- created_object_code = create_objects.create(object, element_position_library)
- if created_object_code == 200:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Create {} object successfully.".format(object["type"], flush=True))
- elif created_object_code != 200:
- result = "Fail to create {} rule.".format(object_configuration["type"])
- return "", "", result
-
- search_objects = SearchObjects(driver)
- element_position_library = get_element_position(object_type)
- searched_object_code, object_uuid, object_description = search_objects.get_object_uuid(object["name"], element_position_library)
- if searched_object_code == 200:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Search {} object successfully.".format(object["type"], flush=True))
- elif searched_object_code == 200:
- result = "Fail to search {} rule uuid.".format(object_configuration["type"])
- return "", "", result
-
- object_uuids_temp_dict["type"] = object["type"]
- object_uuids_temp_dict["uuid"] = object_uuid
- object_uuids_temp_dict["name"] = object["name"]
- object_uuids_temp_dict["description"] = object_description
- object_uuids_list.append(object_uuids_temp_dict)
- rule_uuids_tuple = tuple(object_uuids_list)
-
- return rule_uuids_tuple,result
- except Exception as e:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "When creating object by ui, the exception error: ", str(e), flush=True)
- return "", "When creating object by ui, the exception error: " + str(e)
diff --git a/support/ui_utils/delete_objects_example.py b/support/ui_utils/delete_objects_example.py
deleted file mode 100644
index 41cf40990..000000000
--- a/support/ui_utils/delete_objects_example.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- coding: UTF-8 -*-
-import os
-import sys
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
-import support.ui_utils.env
-from support.api_utils.log_in import LogIn
-from support.api_utils.delete_objects import DeleteObjects as DeleteObjectsAPI
-from support.general_ui_utils.object.search_objects import SearchObjects
-from support.general_ui_utils.object.delete_objects import DeleteObjects
-from support.ui_utils.element_position.map_element_position_library import *
-from datetime import datetime
-
-class DeleteObjectsExample:
- def __init__(self, driver):
- self.driver = driver
-
- def delete_objects(self, parameter, objects_tuple):
- result = ""
- for obj in objects_tuple:
- # 删除object
- search_object = SearchObjects(self.driver)
- element_position_map = get_element_position(obj["type"])
- search_object_code, first_row_checkbox_element = search_object.get_first_object(obj["uuid"],element_position_map)
- if search_object_code == 200:
- delete_Object = DeleteObjects(self.driver)
- delete_object_code = delete_Object.delete(element_position_map,first_row_checkbox_element)
- if delete_object_code == 200:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete {} object successfully.".format(obj["type"]), flush=True)
- elif delete_object_code != 200:
- result = result + " In addition, fail to delete {} object.".format(obj["type"])
- else:
- result = result + " In addition, fail to search {} object.".format(obj["type"])
diff --git a/support/ui_utils/edit_objects_example.py b/support/ui_utils/edit_objects_example.py
deleted file mode 100644
index 8b3207325..000000000
--- a/support/ui_utils/edit_objects_example.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- coding: UTF-8 -*-
-import os
-import sys
-
-sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
-from support.general_ui_utils.object.edit_objects_temp import EditObjects
-from support.general_ui_utils.object.search_objects import SearchObjects
-from support.ui_utils.element_position.map_element_position_library import *
-from datetime import datetime
-
-
-class EditObjectsExample:
- def edit_objects(self, objects_tuple,first_row_checkbox_element,object_configuration, driver):
- try:
- for obj in objects_tuple:
- # 删除object
- search_object = SearchObjects(driver)
- element_position_map = get_element_position(obj["type"])
- search_object_code, first_row_checkbox_element = search_object.get_first_object(obj["uuid"],element_position_map)
- if search_object_code == 200:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search {} object successfully.".format(obj["type"], flush=True))
- edit_objects = EditObjects(driver)
- edit_object_code = edit_objects.edit(object_configuration, element_position_map,first_row_checkbox_element)
- if edit_object_code == 200:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit {} object successfully.".format(obj["type"], flush=True))
- elif edit_object_code != 200:
- result = "Fail to create {} rule.".format(obj["type"])
- return "", "", result
- elif search_object_code == 200:
- result = "Fail to search {} rule uuid.".format(obj["type"])
- return "", "", result
-
- except Exception as e:
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When creating rule by ui, the exception error: ", str(e), flush=True)
- return "", "When creating rule by ui, the exception error: " + str(e)
diff --git a/support/ui_utils/element_position/map_element_position_library.py b/support/ui_utils/element_position/map_element_position_library.py
index 7c18668cb..de3b70531 100644
--- a/support/ui_utils/element_position/map_element_position_library.py
+++ b/support/ui_utils/element_position/map_element_position_library.py
@@ -1025,6 +1025,7 @@ object_ip_object_element_position = {
},
"search": {
"objectListPage_searchLabel_posXpath": ipObjectListPage_searchLabel_posXpath,
+ "objectListPage_searchLabel_selectName_posXpath":ipObjectListPage_searchLabel_selectName_posXpath,
"objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath,
"objectListPage_tableTbody_posXpath": ipObjectListPage_tableTbody_posXpath,
"objectListPage_search_input_posXpath": ipObjectListPage_search_input_posXpath,
@@ -1571,11 +1572,26 @@ object_application_object_element_position = {
"signature_artibute_protocols":app_signature_artibute_protocols__posXpath,
"objectPage_okButton_posXpath": application_ok_button_posXpath,
"attribute_add_object_posXpath":app_signature_attribute_add_object_posXpath,
-
+ },
+ "edit": {
+ "signature_inputName_posXpath": app_signature_input_name_posXpath,
+ "signature_add_artibutem_posXpath": app_signature_add_button_posXpath,
+ "signature_condition_select_up_posXpath": app_signature_condition_select_up_posXpath,
+ "signature_new_condition__posXpath": app_signature_new_condition__posXpath,
+ "signature_new_not_condition__posXpath":app_signature_new_not_condition__posXpath,
+ "signature_add_artibute_button_posXpath":app_signature_add_artibute_button_posXpath,
+ "signature_artibute_protocols":app_signature_artibute_protocols__posXpath,
+ "objectPage_okButton_posXpath": application_ok_button_posXpath,
+ "attribute_add_object_posXpath":app_signature_attribute_add_object_posXpath,
},
"search": {
- "objectListPage_searchLabel_posId": ObjectListPage_searchLabel_posId,
- "objectListPage_tableTbody_posXpath": ObjectListPage_tableTbody_posXpath
+ "objectListPage_searchLabel_posXpath": ipObjectListPage_searchLabel_posXpath,
+ "objectListPage_searchLabel_selectName_posXpath":ipObjectListPage_searchLabel_selectName_posXpath,
+ "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath,
+ "objectListPage_tableTbody_posXpath": ipObjectListPage_tableTbody_posXpath,
+ "objectListPage_search_input_posXpath": ipObjectListPage_search_input_posXpath,
+ "objectListPage_search_dropDown_item_posXpath": ipObjectListPage_search_dropDown_item_posXpath,
+ "objectListPage_search_button_posXpath": ipObjectListPage_search_button_posXpath
},
"delete": {
"objectListPage_allSelect_posXpath": ObjectListPage_allSelect_posXpath,
@@ -1643,9 +1659,20 @@ object_flag_object_element_position = {
"ObjectPage_sameItem_addItem_posXpath": urlObjectPage_sameItem_addItem_posXpath,
"ObjectPage_sameItem_inputItem_posXpath": urlObjectPage_sameItem_inputItem_posXpath,
},
+ "edit": {
+ "ObjectListPage_editButton_posXpath": ipObjectListPage_editButton_posXpath,
+ "objectPage_addItem_posXpath": flagObjectPage_addItem_posXpath,
+ "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath,
+ "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath,
+ "objectPage_inputItem_posXpath": accountObjectPage_inputItem_posXpath,
+ "objectPage_button_saveItem_posXpath": accountObjectPage_button_saveItem_posXpath,
+ "objectPage_okButton_posXpath": accountObjectPage_okButton_posXpath,
+ },
"search": {
+ "objectListPage_search_button_posXpath":apnObjectListPage_search_button_posXpath,
"objectListPage_searchLabel_posXpath": accountObjectPage_searchLabel_posXpath,
"objectListPage_searchLabel_selectName_posXpath": '//*[@class="base-Popper-root MuiAutocomplete-listbox css-18r31z0"]//li[1]',
+ "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath,
"objectListPage_tableTbody_posXpath": accountObjectListPage_tableTbody_posXpath,
},
@@ -1713,6 +1740,33 @@ object_tunnel_object_element_position = {
"objectPage_side_slic_create_button_posXpath":tunnelObjectPage_create_ip_button_posXpath,
"ObjectPage_side_slic_Cancel_posXpath":tunnelObjectPage_side_slic_Cancel_posXpath
},
+ "edit": {
+ "ObjectListPage_editButton_posXpath": ipObjectListPage_editButton_posXpath,
+ "objectPage_endition_a_addItem_posXpath": tunnelObjectListPage_endition_a_add_item_button,
+ "objectPage_endition_b_addItem_posXpath": tunnelObjectListPage_endition_b_add_item_button,
+ "objectPage_endition_a_editItem_posXpath":tunnelObjectListPage_endition_a_edit_item_button,
+ "objectPage_endition_b_editItem_posXpath":tunnelObjectListPage_endition_b_edit_item_button,
+ "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath,
+ "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath,
+ "objectPage_okButton_posXpath": tunnelObjectPage_okButton_posXpath,
+ "objectPage_side_slic_create_button_posXpath":tunnelObjectPage_create_ip_button_posXpath,
+ "ObjectPage_side_slic_Cancel_posXpath":tunnelObjectPage_side_slic_Cancel_posXpath
+ },
+ "search": {
+ "objectListPage_searchLabel_posXpath": imsiObjectListPage_searchLabel_posXpath,
+ "objectListPage_searchLabel_selectName_posXpath": ipObjectListPage_searchLabel_selectName_posXpath,
+ "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath,
+ "objectListPage_tableTbody_posXpath": ipObjectListPage_tableTbody_posXpath,
+ "objectListPage_search_input_posXpath": ipObjectListPage_search_input_posXpath,
+ "objectListPage_search_dropDown_item_posXpath": ipObjectListPage_search_dropDown_item_posXpath,
+ "objectListPage_search_button_posXpath": ipObjectListPage_search_button_posXpath
+ },
+ "delete": {
+ "objectListPage_allSelect_posXpath": ipObjectListPage_allSelect_posXpath,
+ "objectListPage_deleteButton_posXpath": ipObjectListPage_deleteButton_posXpath,
+ "objectListPage_deleteButton_warningYes_posXpath": ipObjectListPage_deleteButton_warningYes_posXpath
+ }
+
}
object_interval_object_element_position = {
diff --git a/support/ui_utils/element_position/object_element_position.py b/support/ui_utils/element_position/object_element_position.py
index 99af9aaec..9c7143e64 100644
--- a/support/ui_utils/element_position/object_element_position.py
+++ b/support/ui_utils/element_position/object_element_position.py
@@ -82,7 +82,7 @@ ipObjectListPage_editButton_posXpath = "//span[@class='action-edit inline-flex m
ipObjectListPage_dropDown_createButton_posXpath = "//ul[@class='base-Popper-root MuiMenu-root Mui-expanded MuiMenu-variantOutlined MuiMenu-colorNeutral MuiMenu-sizeMd css-1iuehdr']//li[1]" # 从下拉菜单中选择Address
ipObjectListPage_dropDown_createGroupButton_posId = "//ul[@class='base-Popper-root MuiMenu-root Mui-expanded MuiMenu-variantOutlined MuiMenu-colorNeutral MuiMenu-sizeMd css-1iuehdr']//li[2]"
ipObjectListPage_searchLabel_posXpath = '//*[@class="MuiAutocomplete-wrapper MuiAutocomplete-multiple css-1h1ala5"]/input' # 查询框id
-ipObjectListPage_searchLabel_selectName_posXpath = '//*[@class="MuiInput-input css-1u0jcuo"]' # 查询Name
+ipObjectListPage_searchLabel_selectName_posXpath = objectListPage_search_select_Name_posXpath # 查询Name
ipObjectListPage_deleteButton_posXpath = '//*[@class="action-delete inline-flex mr-[8px] "]'
ipObjectListPage_deleteButton_warningYes_posXpath = '//button[normalize-space(text())="Yes"]'
ipObjectListPage_deleteButton_warningNo_posCss = "body>.el-dialog__wrapper .delComponents-close span"
@@ -410,8 +410,10 @@ application_ok_button_posXpath = "(//div[@class='form-action bg-[--color-backgro
#tunnel
tunnelObjectListPage_createButton_posXpath = "//div[@class='flex justify-start items-center mr-[20px]']//span[text()='Create']"
tunnelObjectListPage_inputName_posXpath ="//*[@class='tunnel-object-name']//input"
-tunnelObjectListPage_endition_a_add_item_button="//div[@class='tunnel-object-endpointA']//i[@class='iconfont icon-Create1 font-[700]']"
-tunnelObjectListPage_endition_b_add_item_button="//div[@class='tunnel-object-endpointB']//i[@class='iconfont icon-Create1 font-[700]']"
+tunnelObjectListPage_endition_a_add_item_button="//div[@class='tunnel-object-endpointA']//i[contains(@class,'iconfont icon-Create1')]"
+tunnelObjectListPage_endition_b_add_item_button="//div[@class='tunnel-object-endpointB']//i[contains(@class,'iconfont icon-Create1')]"
+tunnelObjectListPage_endition_a_edit_item_button = "//div[@class='tunnel-object-endpointA']//i[@class='iconfont icon-Edit absolute right-[24px] cursor-pointer']"
+tunnelObjectListPage_endition_b_edit_item_button = "//div[@class='tunnel-object-endpointB']//i[@class='iconfont icon-Edit absolute right-[24px] cursor-pointer']"
tunnelObjectListPage_edit_Type_posXpath="//div[@class='tunnel-object-type']//button[@class='MuiSelect-button css-1qmzz5g']"
tunnelObjectListPage_type_gre_posXpath="//ul[@class='base-Popper-root MuiSelect-listbox Mui-expanded css-icfck1']//*[normalize-space(text())='GRE']"
tunnelObjectListPage_type_ip_posXpath="//ul[@class='base-Popper-root MuiSelect-listbox Mui-expanded css-icfck1']//*[normalize-space(text())='IPv4/IPv6']"
diff --git a/support/ui_utils/objects/create_objects_example.py b/support/ui_utils/objects/create_objects_example.py
index 16fe1ad09..8e939a8a0 100644
--- a/support/ui_utils/objects/create_objects_example.py
+++ b/support/ui_utils/objects/create_objects_example.py
@@ -220,47 +220,50 @@ class CreateObjects:
self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_upBoundary_posXpath"]).send_keys(eval(str(data_int))[1]) # 于item 下up_boundary value输入框键入item_value
self.driver.find_element(By.XPATH, creation_element_position["objectPage_button_saveItem_posXpath"]).click() # 点击保存按钮
elif object_type == "application":
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputLongName_posXpath"]).send_keys(object["application"]["app_longname"]) # input long name
- # self.driver.find_element(By.XPATH, creation_element_position[""]).send_keys("Your description") # input description
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_category_dropwmn_posXpath"]).click() # category
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_category_xpath"].format(replaceValue=object["application"]["app_properties"]["category"])).click() #
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_subcategory_dropwmn_posXpath"]).click() # subcategory
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_sub_category_xpath"].format(replaceValue=object["application"]["app_properties"]["subcategory"])).click() #
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_content_dropwmn_posXpath"]).click() # content
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_content_xpath"].format(replaceValue=object["application"]["app_properties"]["content"])).click() #
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_risk_dropwmn_posXpath"]).click() # risk 0
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_risi_xpath"].format(replaceValue=object["application"]["app_properties"]["risk"])).click()
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_characteristics_xpath"].format(replaceValue=object["application"]["app_properties"]["characteristics"])).click()
- #添加signature
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click()
- self.driver.find_element(By.XPATH, creation_element_position["objectPage_create_signature_posXpath"]).click()
- for m in range(len(object["app_surrogates"])):
- app_surrogates= object["app_surrogates"][m]
- for i in range(len(app_surrogates["signature_sequence"])):
- app_signature= app_surrogates["signature_sequence"][i]
- self.driver.find_element(By.XPATH,creation_element_position["signature_inputName_posXpath"]).send_keys(app_signature["signature"]["name"])
- self.driver.find_element(By.XPATH, creation_element_position["signature_add_artibutem_posXpath"]).click()
- for j in range(len(app_signature["signature"]["and_conditions"])):
- app_and_condition= app_signature["signature"]["and_conditions"][j]
- self.driver.find_element(By.XPATH, creation_element_position["signature_condition_select_up_posXpath"]).click()
- if app_and_condition["negate_option"] == False:
- self.driver.find_element(By.XPATH, creation_element_position["signature_new_condition__posXpath"]).click()
- else:self.driver.find_element(By.XPATH, creation_element_position["signature_new_not_condition__posXpath"]).click()
- self.driver.find_element(By.XPATH, creation_element_position["signature_add_artibute_button_posXpath"]).click()
- for n in range(len(app_and_condition["or_conditions"])):
- app_or_condition= app_and_condition["or_conditions"][n]
- self.driver.find_element(By.XPATH,"//li[@class = 'MuiTreeItem-root css-105mfs8']//div[text()='common']").click()
- self.driver.find_element(By.XPATH,creation_element_position["signature_artibute_protocols"].format(replaceValue=app_or_condition["attribute_name"])).click()
- self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
- self.driver.find_element(By.XPATH,creation_element_position["attribute_add_object_posXpath"]).click()
- self.driver.find_element(By.XPATH,creation_element_position["objectPage_create_signature_posXpath"]+"[2]").click()
- common_object_element_position = get_element_position(app_or_condition["type"])
- self.create_common_objects(app_or_condition,common_object_element_position)
- self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[4]").click()
- self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
- self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[3]").click()
- self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[2]").click()
- self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[1]//button[text()='Cancel']").click()
+ if "items" in object.keys():
+ return 200
+ elif "application" in object.keys():
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputLongName_posXpath"]).send_keys(object["application"]["app_longname"]) # input long name
+ # self.driver.find_element(By.XPATH, creation_element_position[""]).send_keys("Your description") # input description
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_category_dropwmn_posXpath"]).click() # category
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_category_xpath"].format(replaceValue=object["application"]["app_properties"]["category"])).click() #
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_subcategory_dropwmn_posXpath"]).click() # subcategory
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_sub_category_xpath"].format(replaceValue=object["application"]["app_properties"]["subcategory"])).click() #
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_content_dropwmn_posXpath"]).click() # content
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_content_xpath"].format(replaceValue=object["application"]["app_properties"]["content"])).click() #
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_risk_dropwmn_posXpath"]).click() # risk 0
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_risi_xpath"].format(replaceValue=object["application"]["app_properties"]["risk"])).click()
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_characteristics_xpath"].format(replaceValue=object["application"]["app_properties"]["characteristics"])).click()
+ #添加signature
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH, creation_element_position["objectPage_create_signature_posXpath"]).click()
+ for m in range(len(object["app_surrogates"])):
+ app_surrogates= object["app_surrogates"][m]
+ for i in range(len(app_surrogates["signature_sequence"])):
+ app_signature= app_surrogates["signature_sequence"][i]
+ self.driver.find_element(By.XPATH,creation_element_position["signature_inputName_posXpath"]).send_keys(app_signature["signature"]["name"])
+ self.driver.find_element(By.XPATH, creation_element_position["signature_add_artibutem_posXpath"]).click()
+ for j in range(len(app_signature["signature"]["and_conditions"])):
+ app_and_condition= app_signature["signature"]["and_conditions"][j]
+ self.driver.find_element(By.XPATH, creation_element_position["signature_condition_select_up_posXpath"]).click()
+ if app_and_condition["negate_option"] == False:
+ self.driver.find_element(By.XPATH, creation_element_position["signature_new_condition__posXpath"]).click()
+ else:self.driver.find_element(By.XPATH, creation_element_position["signature_new_not_condition__posXpath"]).click()
+ self.driver.find_element(By.XPATH, creation_element_position["signature_add_artibute_button_posXpath"]).click()
+ for n in range(len(app_and_condition["or_conditions"])):
+ app_or_condition= app_and_condition["or_conditions"][n]
+ self.driver.find_element(By.XPATH,"//li[@class = 'MuiTreeItem-root css-105mfs8']//div[text()='common']").click()
+ self.driver.find_element(By.XPATH,creation_element_position["signature_artibute_protocols"].format(replaceValue=app_or_condition["attribute_name"])).click()
+ self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
+ self.driver.find_element(By.XPATH,creation_element_position["attribute_add_object_posXpath"]).click()
+ self.driver.find_element(By.XPATH,creation_element_position["objectPage_create_signature_posXpath"]+"[2]").click()
+ common_object_element_position = get_element_position(app_or_condition["type"])
+ self.create_objects_by_side_slide(app_or_condition,common_object_element_position)
+ self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[4]").click()
+ self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
+ self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[3]").click()
+ self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[2]").click()
+ self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[1]//button[text()='Cancel']").click()
elif object_type == "tunnel":
if len(object["tunnel"]["and_conditions"]) == 1:
tunnel_endition_a = object["tunnel"]["and_conditions"][0]
@@ -277,8 +280,9 @@ class CreateObjects:
for i in range(len(tunnel_endition_a["or_conditions"])):
self.driver.find_element(By.XPATH,creation_element_position["objectPage_endition_a_addItem_posXpath"]).click()
self.driver.find_element(By.XPATH, creation_element_position["objectPage_side_slic_create_button_posXpath"]).click()
+ time.sleep(1)
common_object_element_position = get_element_position(tunnel_endition_a["or_conditions"][i]["type"])
- self.create_common_objects(tunnel_endition_a["or_conditions"][i],common_object_element_position)
+ self.create_objects_by_side_slide(tunnel_endition_a["or_conditions"][i],common_object_element_position)
self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[2]").click()
self.driver.find_element(By.XPATH,creation_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click()
if len(object["tunnel"]["and_conditions"]) == 2:
@@ -287,12 +291,9 @@ class CreateObjects:
self.driver.find_element(By.XPATH, creation_element_position["objectPage_side_slic_create_button_posXpath"]).click()
for i in range(len(tunnel_endition_b["or_conditions"])):
- self.create_common_objects(tunnel_endition_b["or_conditions"][i], common_object_element_position)
+ self.create_objects_by_side_slide(tunnel_endition_b["or_conditions"][i], common_object_element_position)
self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"] + "[2]").click()
self.driver.find_element(By.XPATH,creation_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click()
-
-
-
elif object_type == "port":
for i in range(len(object["items"])):
if object["items"][i]["op"] == "add":
diff --git a/support/ui_utils/objects/delete_objects_example.py b/support/ui_utils/objects/delete_objects_example.py
index fa9122626..626278538 100644
--- a/support/ui_utils/objects/delete_objects_example.py
+++ b/support/ui_utils/objects/delete_objects_example.py
@@ -33,6 +33,24 @@ class DeleteObjects:
self.driver.find_element(By.XPATH, deletion_element_position["objectListPage_deleteButton_posXpath"]).click()
self.driver.find_element(By.XPATH,deletion_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click()
time.sleep(3)
+ if object["type"] == "tunnel":
+ element_position_library = get_element_position("ip")
+ page_jump_element_position = element_position_library["page_jump"]
+ search_element_position = element_position_library["search"]
+ page_jump = PageJump(self.driver)
+ time.sleep(0.5)
+ page_jump.jump_sub_object_page(page_jump_element_position)
+ time.sleep(3)
+ self.driver.find_element(By.XPATH,search_element_position["objectListPage_searchLabel_posXpath"]).click()
+ self.driver.find_element(By.XPATH,search_element_position["objectListPage_searchLabel_posXpath"]).send_keys("tunnel")
+ self.driver.find_element(By.XPATH, search_element_position["objectListPage_searchLabel_selectName_posXpath"]).click()
+ self.driver.find_element(By.XPATH,search_element_position["objectListPage_search_button_posXpath"]).click()
+ time.sleep(2)
+ objects_list_elements = self.driver.find_elements(By.XPATH,"//div[@class='MuiDataGrid-virtualScrollerContent css-0']/div/div")
+ if len(objects_list_elements) != 0:
+ self.driver.find_element(By.XPATH,"//input[@class='MuiCheckbox-input css-1jj0cvj']").click()
+ self.driver.find_element(By.XPATH,deletion_element_position["objectListPage_deleteButton_posXpath"]).click()
+ self.driver.find_element(By.XPATH, deletion_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click()
return 200
except Exception as e:
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], f"Exception: {e}",flush=True)
diff --git a/support/ui_utils/objects/edit_objects_example.py b/support/ui_utils/objects/edit_objects_example.py
index 7b2f30f9a..9ceb6c17c 100644
--- a/support/ui_utils/objects/edit_objects_example.py
+++ b/support/ui_utils/objects/edit_objects_example.py
@@ -129,7 +129,94 @@ class EditObjects:
self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[16]").click()
elif key_flag == "Tunneling" and new_item[key_flag] == True:
self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[17]").click()
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_button_saveItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_button_saveItem_posXpath"]).click()
+ elif src_item != "":
+ self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_edit_item_posXpath"]).click()
+ #对源item双击取消
+ for key_flag in src_item:
+ if key_flag == "Bulky":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[2]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[2]").click()
+ elif key_flag == "CBR Streaming":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[3]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[3]").click()
+ elif key_flag == "Client is Local" :
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[4]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[4]").click()
+ elif key_flag == "Server is Local":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[5]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[5]").click()
+ elif key_flag == "Download":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[6]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[6]").click()
+ elif key_flag == "Interactive":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[7]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[7]").click()
+ elif key_flag == "Inbound" :
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[8]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[8]").click()
+ elif key_flag == "Outbound":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[9]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[9]").click()
+ elif key_flag == "Pseudo Unidirectional":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[10]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[10]").click()
+ elif key_flag == "Streaming":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[11]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[11]").click()
+ elif key_flag == "Unidirectional":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[12]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[12]").click()
+ elif key_flag == "Random looking":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[13]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[13]").click()
+ elif key_flag == "C2S":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[14]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[14]").click()
+ elif key_flag == "S2C":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[15]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[15]").click()
+ elif key_flag == "Bidirectional" :
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[16]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[16]").click()
+ elif key_flag == "Tunneling":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[17]").click()
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[17]").click()
+ #添加新item
+ for key_flag in new_item:
+ if key_flag == "Bulky" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[2]").click()
+ elif key_flag == "CBR Streaming":
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[3]").click()
+ elif key_flag == "Client is Local" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[4]").click()
+ elif key_flag == "Server is Local" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[5]").click()
+ elif key_flag == "Download" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[6]").click()
+ elif key_flag == "Interactive" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[7]").click()
+ elif key_flag == "Inbound" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[8]").click()
+ elif key_flag == "Outbound" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[9]").click()
+ elif key_flag == "Pseudo Unidirectional" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[10]").click()
+ elif key_flag == "Streaming" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[11]").click()
+ elif key_flag == "Unidirectional" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[12]").click()
+ elif key_flag == "Random looking" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[13]").click()
+ elif key_flag == "C2S" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[14]").click()
+ elif key_flag == "S2C" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[15]").click()
+ elif key_flag == "Bidirectional" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[16]").click()
+ elif key_flag == "Tunneling" and new_item[key_flag] == True:
+ self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[17]").click()
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_button_saveItem_posXpath"]).click()
elif object_type == "interval":
if src_item == "":
data_int = new_item.split("-")
@@ -152,76 +239,81 @@ class EditObjects:
self.driver.find_element(By.XPATH, edit_element_position["objectPage_inputItem_upBoundary_posXpath"]).send_keys(eval(str(data_int))[1]) # 于item 下up_boundary value输入框键入item_value
self.driver.find_element(By.XPATH, edit_element_position["objectPage_button_saveItem_posXpath"]).click() # 点击保存按钮
elif object_type == "application":
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_inputLongName_posXpath"]).send_keys(object["application"]["app_longname"]) # input long name
- # self.driver.find_element(By.XPATH, edit_element_position[""]).send_keys("Your description") # input description
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_select_category_dropwmn_posXpath"]).click() # category
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_category_xpath"].format(replaceValue=object["application"]["app_properties"]["category"])).click() #
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_select_subcategory_dropwmn_posXpath"]).click() # subcategory
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_sub_category_xpath"].format(replaceValue=object["application"]["app_properties"]["subcategory"])).click() #
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_select_content_dropwmn_posXpath"]).click() # content
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_content_xpath"].format(replaceValue=object["application"]["app_properties"]["content"])).click() #
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_select_risk_dropwmn_posXpath"]).click() # risk 0
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_risi_xpath"].format(replaceValue=object["application"]["app_properties"]["risk"])).click()
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_characteristics_xpath"].format(replaceValue=object["application"]["app_properties"]["characteristics"])).click()
- #添加signature
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click()
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_create_signature_posXpath"]).click()
- for m in range(len(object["app_surrogates"])):
- app_surrogates= object["app_surrogates"][m]
- for i in range(len(app_surrogates["signature_sequence"])):
- app_signature= app_surrogates["signature_sequence"][i]
- self.driver.find_element(By.XPATH,edit_element_position["signature_inputName_posXpath"]).send_keys(app_signature["signature"]["name"])
- self.driver.find_element(By.XPATH, edit_element_position["signature_add_artibutem_posXpath"]).click()
- for j in range(len(app_signature["signature"]["and_conditions"])):
- app_and_condition= app_signature["signature"]["and_conditions"][j]
- self.driver.find_element(By.XPATH, edit_element_position["signature_condition_select_up_posXpath"]).click()
- if app_and_condition["negate_option"] == False:
- self.driver.find_element(By.XPATH, edit_element_position["signature_new_condition__posXpath"]).click()
- else:self.driver.find_element(By.XPATH, edit_element_position["signature_new_not_condition__posXpath"]).click()
- self.driver.find_element(By.XPATH, edit_element_position["signature_add_artibute_button_posXpath"]).click()
- for n in range(len(app_and_condition["or_conditions"])):
- app_or_condition= app_and_condition["or_conditions"][n]
- self.driver.find_element(By.XPATH,"//li[@class = 'MuiTreeItem-root css-105mfs8']//div[text()='common']").click()
- self.driver.find_element(By.XPATH,edit_element_position["signature_artibute_protocols"].format(replaceValue=app_or_condition["attribute_name"])).click()
- self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
- self.driver.find_element(By.XPATH,edit_element_position["attribute_add_object_posXpath"]).click()
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_create_signature_posXpath"]+"[2]").click()
- common_object_element_position = get_element_position(app_or_condition["type"])
- self.create_common_objects(app_or_condition,common_object_element_position)
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[4]").click()
- self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[3]").click()
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[2]").click()
- self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[1]//button[text()='Cancel']").click()
- elif object_type == "tunnel":
- if len(object["tunnel"]["and_conditions"]) == 1:
- tunnel_endition_a = object["tunnel"]["and_conditions"][0]
- elif len(object["tunnel"]["and_conditions"]) == 2:
- tunnel_endition_a = object["tunnel"]["and_conditions"][0]
- tunnel_endition_b = object["tunnel"]["and_conditions"][1]
-
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_edit_tunnel_type_posXpath"]).click()
- if object["tunnel"]["action_parameter"]["type"] == "IP":
- self.driver.find_element(By.XPATH, edit_element_position["objectListPage_type_ip_posXpath"]).click()
- elif object["tunnel"]["action_parameter"]["type"] == "GRE":
- self.driver.find_element(By.XPATH, edit_element_position["objectListPage_type_gre_posXpath"]).click()
-
- for i in range(len(tunnel_endition_a["or_conditions"])):
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_a_addItem_posXpath"]).click()
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_side_slic_create_button_posXpath"]).click()
- common_object_element_position = get_element_position(tunnel_endition_a["or_conditions"][i]["type"])
- self.create_common_objects(tunnel_endition_a["or_conditions"][i],common_object_element_position)
+ if src_item == "":
+ #添加signature
+ self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH, edit_element_position["objectPage_create_signature_posXpath"]).click()
+ for m in range(len(new_item)):
+ app_surrogates= new_item[m]
+ for i in range(len(app_surrogates["signature_sequence"])):
+ app_signature= app_surrogates["signature_sequence"][i]
+ self.driver.find_element(By.XPATH,edit_element_position["signature_inputName_posXpath"]).send_keys(app_signature["signature"]["name"])
+ self.driver.find_element(By.XPATH, edit_element_position["signature_add_artibutem_posXpath"]).click()
+ for j in range(len(app_signature["signature"]["and_conditions"])):
+ app_and_condition= app_signature["signature"]["and_conditions"][j]
+ self.driver.find_element(By.XPATH, edit_element_position["signature_condition_select_up_posXpath"]).click()
+ if app_and_condition["negate_option"] == False:
+ self.driver.find_element(By.XPATH, edit_element_position["signature_new_condition__posXpath"]).click()
+ else:self.driver.find_element(By.XPATH, edit_element_position["signature_new_not_condition__posXpath"]).click()
+ self.driver.find_element(By.XPATH, edit_element_position["signature_add_artibute_button_posXpath"]).click()
+ for n in range(len(app_and_condition["or_conditions"])):
+ app_or_condition= app_and_condition["or_conditions"][n]
+ self.driver.find_element(By.XPATH,"//li[@class = 'MuiTreeItem-root css-105mfs8']//div[text()='common']").click()
+ self.driver.find_element(By.XPATH,edit_element_position["signature_artibute_protocols"].format(replaceValue=app_or_condition["attribute_name"])).click()
+ self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
+ self.driver.find_element(By.XPATH,edit_element_position["attribute_add_object_posXpath"]).click()
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_create_signature_posXpath"]+"[2]").click()
+ common_object_element_position = get_element_position(app_or_condition["type"])
+ self.create_objects_by_side_slide(app_or_condition,common_object_element_position)
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[4]").click()
+ self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click()
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[3]").click()
self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[2]").click()
- self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click()
- if len(object["tunnel"]["and_conditions"]) == 2:
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_b_addItem_posXpath"]).click()
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_b_addItem_posXpath"]).click()
- self.driver.find_element(By.XPATH, edit_element_position["objectPage_side_slic_create_button_posXpath"]).click()
-
- for i in range(len(tunnel_endition_b["or_conditions"])):
- self.create_common_objects(tunnel_endition_b["or_conditions"][i], common_object_element_position)
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"] + "[2]").click()
+ self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[1]//button[text()='Cancel']").click()
+ elif src_item != "":
+ self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH,"//input[@class='MuiInput-input css-za5rna']").send_keys(src_item["signature_sequence"][0]["signature"]["name"] + Keys.ENTER)
+ self.driver.find_element(By.XPATH,"//i[@class='iconfont icon-Edit !text-[var(--color-text)]']").click()
+ name_input_field = self.driver.find_element(By.XPATH, edit_element_position["signature_inputName_posXpath"])
+ name_input_field.send_keys(Keys.CONTROL, 'a') # 或使用 Keys.COMMAND 在 macOS
+ name_input_field.send_keys(Keys.DELETE)
+ name_input_field.send_keys("signature_edit_name")
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"] + "[2]").click()
+
+ elif object_type == "tunnel":
+ if src_item == "":
+ if len(new_item) == 1:
+ tunnel_endition_a = new_item[0]
+ elif len(new_item) == 2:
+ tunnel_endition_a = new_item[0]
+ tunnel_endition_b = new_item[1]
+
+ for i in range(len(tunnel_endition_a["or_conditions"])):
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_a_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH, edit_element_position["objectPage_side_slic_create_button_posXpath"]).click()
+ time.sleep(1)
+ common_object_element_position = get_element_position(tunnel_endition_a["or_conditions"][i]["type"])
+ self.create_objects_by_side_slide(tunnel_endition_a["or_conditions"][i],common_object_element_position)
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"]+"[2]").click()
self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click()
+ if len(new_item) == 2:
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_b_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_b_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH, edit_element_position["objectPage_side_slic_create_button_posXpath"]).click()
+
+ for i in range(len(tunnel_endition_b["or_conditions"])):
+ self.create_objects_by_side_slide(tunnel_endition_b["or_conditions"][i], common_object_element_position)
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_okButton_posXpath"] + "[2]").click()
+ self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click()
+ elif src_item != "":
+ if len(src_item) == 1:
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_endition_a_editItem_posXpath"]).click()
+ name_input_field = self.driver.find_element(By.XPATH,"//div[@class='ip-object-name']//input")
+ name_input_field.send_keys(Keys.CONTROL, 'a') # 或使用 Keys.COMMAND 在 macOS
+ name_input_field.send_keys(Keys.DELETE)
+ name_input_field.send_keys("tunnel_edit_A")
+ self.driver.find_element(By.XPATH, edit_element_position["objectPage_okButton_posXpath"] + "[2]").click()
+ self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click()
elif object_type == "ip_learning":
self.driver.find_element(By.XPATH,edit_element_position["objectPage_ipLearningType_posXpath"]).click()
if object["op"] == "add":
@@ -243,13 +335,6 @@ class EditObjects:
self.driver.find_element(By.XPATH,edit_element_position["objectPage_voteClients_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["vote_client_num"])
self.driver.find_element(By.XPATH,edit_element_position["objectPage_learnedIPLimits_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["goal_upper_limit"])
else:
- # if object_type == "ip":
- # send_data = object["items"]["ip"]
- # edit_data = object["items"][i]["edit_ip"]
- # if object_type == "imsi":
- # send_data = object["items"][i]["expression"]
- # elif object_type == "imei":
- # send_data = object["items"][i]["expression"]
if src_item == "":
self.driver.find_element(By.XPATH,edit_element_position["objectPage_addItem_posXpath"]).click()
# 适配24.10 版本,需要逐个字符输入
@@ -372,7 +457,7 @@ class EditObjects:
# return 400
- def create_common_objects(self,object,common_object_element_position):
+ def create_objects_by_side_slide(self,object,common_object_element_position):
object_type = object["type"]
edit_element_position = common_object_element_position["create"]
self.driver.find_element(By.XPATH,'//ul[@class="base-Popper-root MuiMenu-root Mui-expanded MuiMenu-variantOutlined MuiMenu-colorNeutral MuiMenu-sizeMd css-131n2dh"]/li[1]').click()
diff --git a/support/ui_utils/ui_client.py b/support/ui_utils/ui_client.py
index 203944bd0..ee18b7d2e 100644
--- a/support/ui_utils/ui_client.py
+++ b/support/ui_utils/ui_client.py
@@ -3,9 +3,6 @@ import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
import support.ui_utils.env
-from support.ui_utils.create_objects_example import CreateObjectsExample
-from support.ui_utils.delete_objects_example import DeleteObjectsExample
-from support.ui_utils.edit_objects_example import EditObjectsExample
from support.ui_utils.objects.create_objects_example import CreateObjects
from support.ui_utils.policies.create_rules import CreateRules
from support.ui_utils.policies.search_rules import SearchRules
diff --git a/tests/object/test_temp/create_application_temp.py b/tests/object/test_temp/create_application_temp.py
index 9265f8df3..d3ce6762f 100644
--- a/tests/object/test_temp/create_application_temp.py
+++ b/tests/object/test_temp/create_application_temp.py
@@ -16,8 +16,7 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions": [
+ object_configuration = [
{
"name": "common_server_fqdn",
"type": "application",
@@ -78,25 +77,109 @@ def run(parameter):
}
],
}
- ],
- "search": {
- "is_fuzzy": False,
- "type": "name"
- },
+ ]
- "audit_log": False # system
- }
+ ui_client = UIClient(parameter)
# 创建
- ui_client = UIClient()
- objects_tuple, ui_error = ui_client.create_objects(object_configuration)
- if len(ui_error) > 0:
- return ui_error
+ code = ui_client.create_objects(object_configuration)
+ if code != 200:
+ return "Fail to create object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Create Object successful ")
+
+ search_type = {
+ "is_fuzzy": False,
+ "type": "",
+ }
+ # 查询
+ objects_tuple, code = ui_client.search_objects("create_account_object", object_configuration, search_type)
objects_list = list(objects_tuple)
- if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0:
- return ""
+ if len(objects_list) == 0:
+ return "Fail to get object uuid."
+ if code != 200:
+ return "Fail to search object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ")
+ # 编辑
+ src_app_signature = {
+ "group_by": "session",
+ "signature_sequence": [
+ {
+ "exclude": 0,
+ "signature": {
+ "name": "common_server_fqdn1",
+ "is_enabled": True,
+ "and_conditions": [
+ {
+ "negate_option": False,
+ "or_conditions": [
+ {
+ "attribute_name": "common.server_fqdn",
+ "type": "fqdn",
+ "name": "sec_fqdn",
+ "items": [
+ {
+ "op": "add",
+ "expr_type": "and",
+ "expression": "youtube.com"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ code = ui_client.edit_objects(objects_tuple, src_item=src_app_signature, new_item="")
+ if code != 200:
+ return "Fail to edit object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ")
+
+ new_app_surrogates = [
+ {
+ "group_by": "session",
+ "signature_sequence": [
+ {
+ "exclude": 0,
+ "signature": {
+ "name": "common_server_fqdn1",
+ "is_enabled": True,
+ "and_conditions": [
+ {
+ "negate_option": False,
+ "or_conditions": [
+ {
+ "attribute_name": "common.server_fqdn",
+ "type": "fqdn",
+ "name": "sec_fqdn",
+ "items": [
+ {
+ "op": "add",
+ "expr_type": "and",
+ "expression": "baidu.com"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item=new_app_surrogates)
+ if code != 200:
+ return "Fail to edit object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ")
+ return ""
except Exception as e:
exception_result = str(e)
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When running test case, the exception error: ", str(e), flush=True)
@@ -104,15 +187,10 @@ def run(parameter):
finally:
# 删除
- if parameter["initiation_method"] == "ui":
- if objects_tuple is not None:
- ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"])
- # elif parameter["initiation_method"] == "api":
- # if not objects_tuple:
- # api_client.delete_rules(rules_tuple)
- # if not objects_tuple:
- # api_client.delete_objects(objects_tuple)
-
+ if objects_tuple:
+ ui_client.delete_objects(objects_tuple)
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete Object successful ")
+ # ui_client.cleanup()
# 统计脚本用时
script_end_time = time.time()
duration = script_end_time - script_start_time
@@ -120,6 +198,7 @@ def run(parameter):
"Duration of running the test case: ", "{:.3f}".format(duration), flush=True)
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],
"Finish test case: " + parameter["test_case_name"], flush=True)
+
# 生成csv报告
update = ReportUpdate()
update.write_result(parameter, result, exception_result)
diff --git a/tests/object/test_temp/create_flag_temp.py b/tests/object/test_temp/create_flag_temp.py
index 8813db9b4..5f32ad81f 100644
--- a/tests/object/test_temp/create_flag_temp.py
+++ b/tests/object/test_temp/create_flag_temp.py
@@ -18,7 +18,7 @@ def run(parameter):
#测试数据
object_configuration = [
{
- "name": "test",
+ "name": "create_flag_object",
"type": "flag",
"member_type": "item",
"statistics_option": "", # random
@@ -49,7 +49,7 @@ def run(parameter):
}
# 查询
- objects_tuple, code = ui_client.search_objects("create_apn_object", object_configuration, search_type)
+ objects_tuple, code = ui_client.search_objects("create_flag_object", object_configuration, search_type)
objects_list = list(objects_tuple)
if len(objects_list) == 0:
return "Fail to get object uuid."
@@ -59,14 +59,26 @@ def run(parameter):
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ")
# 编辑
- # 如果src_item是空,则表示该item是新加
- code = ui_client.edit_objects(objects_tuple, src_item="", new_item="testapn$")
+ src_flag = {
+ "Client is Local": True,
+ "Server is Local": True
+ }
+
+ new_flag = {
+ "Pseudo Unidirectional":True
+ }
+
+ code = ui_client.edit_objects(objects_tuple, src_item=src_flag, new_item=new_flag)
if code != 200:
return "Fail to edit object."
else:
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ")
- # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮
- code = ui_client.edit_objects(objects_tuple, src_item="acdcd$", new_item="^xrwom.fu$")
+ # 如果src_item是空,则表示该item是新加
+
+ new_flag = {
+ "Outbound":True
+ }
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item=new_flag)
if code != 200:
return "Fail to edit object."
else:
diff --git a/tests/object/test_temp/create_tunnel_temp.py b/tests/object/test_temp/create_tunnel_temp.py
index 783407291..ecdff410e 100644
--- a/tests/object/test_temp/create_tunnel_temp.py
+++ b/tests/object/test_temp/create_tunnel_temp.py
@@ -16,10 +16,9 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions":[
+ object_configuration = [
{
- "name": "test",
+ "name": "create_tunnel_object",
"type": "tunnel",
"statistics_option": "", # random
"tunnel": {
@@ -34,7 +33,7 @@ def run(parameter):
"attribute_name": "ATTR_TUNNEL_GTP_ENDPOINT",
"type": "ip",
"sub_type": "ip",
- "name": "sec_srcipA",
+ "name": "tunnel_ipA",
"items": [
{
"op": "add",
@@ -52,7 +51,7 @@ def run(parameter):
"attribute_name": "ATTR_TUNNEL_GTP_ENDPOINT",
"type": "ip",
"sub_type": "ip",
- "name": "sec_srcipB",
+ "name": "tunnel_ipB",
"items": [
{
"op": "add",
@@ -66,22 +65,87 @@ def run(parameter):
]
},
}
- ],
- "search": {
- "is_fuzzy": False,
- "type": "uuid"
- },
- "audit_log": False # system
- }
+ ]
+
+ ui_client = UIClient(parameter)
# 创建
- ui_client = UIClient()
- objects_tuple, ui_error = ui_client.create_objects(object_configuration)
- if len(ui_error) > 0:
- return ui_error
+ code = ui_client.create_objects(object_configuration)
+ if code != 200:
+ return "Fail to create object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Create Object successful ")
+
+ search_type = {
+ "is_fuzzy": False,
+ "type": "",
+ }
+
+ # 查询
+ objects_tuple, code = ui_client.search_objects("create_tunnel_object", object_configuration, search_type)
objects_list = list(objects_tuple)
- if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0:
- return ""
+ if len(objects_list) == 0:
+ return "Fail to get object uuid."
+ if code != 200:
+ return "Fail to search object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ")
+
+ src_tunnel_ip = [
+ {
+ "negate_option": False,
+ "or_conditions": [
+ {
+ "attribute_name": "ATTR_TUNNEL_GTP_ENDPOINT",
+ "type": "ip",
+ "sub_type": "ip",
+ "name": "tunnel_ipA",
+ "items": [
+ {
+ "op": "add",
+ "ip": "1.1.1.1",
+ "interval": "0-65535"
+ }
+ ]
+ }
+ ]
+ },
+ ]
+ code = ui_client.edit_objects(objects_tuple, src_item=src_tunnel_ip,new_item="")
+ if code != 200:
+ return "Fail to edit object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful")
+
+ # 编辑
+ new_tunnel_ip = [
+ {
+ "negate_option": False,
+ "or_conditions": [
+ {
+ "attribute_name": "ATTR_TUNNEL_GTP_ENDPOINT",
+ "type": "ip",
+ "sub_type": "ip",
+ "name": "tunnel_ipC",
+ "items": [
+ {
+ "op": "add",
+ "ip": "6.6.6.6",
+ "interval": "0-65535"
+ }
+ ]
+ }
+ ]
+ },
+ ]
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item=new_tunnel_ip)
+ if code != 200:
+ return "Fail to edit object."
+ else:
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ")
+ # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮
+
+ return ""
except Exception as e:
@@ -91,22 +155,16 @@ def run(parameter):
finally:
# 删除
- if parameter["initiation_method"] == "ui":
- if objects_tuple is not None:
- ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"])
- # elif parameter["initiation_method"] == "api":
- # if not objects_tuple:
- # api_client.delete_rules(rules_tuple)
- # if not objects_tuple:
- # api_client.delete_objects(objects_tuple)
-
+ if objects_tuple:
+ ui_client.delete_objects(objects_tuple)
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete Object successful ")
+ # ui_client.cleanup()
# 统计脚本用时
script_end_time = time.time()
duration = script_end_time - script_start_time
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],
- "Duration of running the test case: ", "{:.3f}".format(duration), flush=True)
- print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],
- "Finish test case: " + parameter["test_case_name"], flush=True)
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Duration of running the test case: ", "{:.3f}".format(duration), flush=True)
+ print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Finish test case: " + parameter["test_case_name"], flush=True)
+
# 生成csv报告
update = ReportUpdate()
update.write_result(parameter, result, exception_result)