summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryouzhijiang <[email protected]>2024-11-26 19:10:58 +0800
committeryouzhijiang <[email protected]>2024-11-26 19:10:58 +0800
commit2b38630962a53b763f06ecb8c6cea479eb6d30f4 (patch)
tree90ac5a7d7185b9f4805397b335c292791a80add6
parent9c0388656c344271a780677eb30ad10f4706823f (diff)
object逻辑调整
-rw-r--r--support/ui_utils/delete_objects_example.py10
-rw-r--r--support/ui_utils/element_position/map_element_position_library.py34
-rw-r--r--support/ui_utils/object/create_objects_example.py2
-rw-r--r--support/ui_utils/object/delete_objects_example.py20
-rw-r--r--support/ui_utils/object/edit_objects_example.py72
-rw-r--r--support/ui_utils/object/search_objects_example.py116
-rw-r--r--support/ui_utils/ui_client.py18
-rw-r--r--tests/object/test_temp/create_account_object_temp.py68
-rw-r--r--tests/object/test_temp/create_fqdn_object_temp.py94
-rw-r--r--tests/object/test_temp/create_ip_learning_objects_temp.py83
-rw-r--r--tests/object/test_temp/create_ip_object_temp.py71
-rw-r--r--tests/object/test_temp/create_url_object_temp.py92
12 files changed, 394 insertions, 286 deletions
diff --git a/support/ui_utils/delete_objects_example.py b/support/ui_utils/delete_objects_example.py
index 059f9f8c6..41cf40990 100644
--- a/support/ui_utils/delete_objects_example.py
+++ b/support/ui_utils/delete_objects_example.py
@@ -31,13 +31,3 @@ class DeleteObjectsExample:
result = result + " In addition, fail to delete {} object.".format(obj["type"])
else:
result = result + " In addition, fail to search {} object.".format(obj["type"])
- # 环境清理
- support.ui_utils.env.teardown()
- # 强制删除
- log_in = LogIn()
- pwd = log_in.encryptPwd(parameter["password"], parameter["api_server"])
- token = log_in.login(parameter["username"], pwd, parameter["api_server"])
- headers = {"Content-Type": "application/json", "Authorization": token}
- objects = DeleteObjectsAPI(parameter, headers)
- objects.delete_objects(objects_tuple)
- return result
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 f9aab6331..1b9b8b59d 100644
--- a/support/ui_utils/element_position/map_element_position_library.py
+++ b/support/ui_utils/element_position/map_element_position_library.py
@@ -1025,7 +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,
"objectListPage_search_dropDown_item_posXpath": ipObjectListPage_search_dropDown_item_posXpath,
@@ -1172,9 +1172,19 @@ object_fqdn_object_element_position = {
"objectPage_okButton_posXpath": fqdnObjectPage_okButton_posXpath,
"objectPage_okButton_warningYes_posXpath": fqdnObjectPage_okButton_warningYes_posXpath
},
+ "edit":{
+ "ObjectListPage_editButton_posXpath":ipObjectListPage_editButton_posXpath,
+ "objectPage_addItem_posXpath": fqdnobjectPage_addItem_posXpath,
+ "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath,
+ "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath,
+ "objectPage_inputItem_posXpath": fqdnObjectPage_inputItem_posXpath,
+ "objectPage_button_saveItem_posXpath": fqdnObjectPage_button_saveItem_posXpath,
+ "objectPage_okButton_posXpath": fqdnObjectPage_okButton_posXpath,
+ },
"search": {
"objectListPage_searchLabel_posXpath": fqdnObjectListPage_searchLabel_posXpath,
"objectListPage_searchLabel_selectName_posXpath": fqdnObjectListPage_searchLabel_selectName_posXpath,
+ "objectListPage_searchLabel_selectID_posXpath":objectListPage_search_select_Id_posXpath,
"objectListPage_tableTbody_posXpath": fqdnObjectListPage_tableTbody_posXpath,
"objectListPage_search_input_posXpath": fqdnObjectListPage_search_input_posXpath,
"objectListPage_search_dropDown_item_posXpath": fqdnObjectListPage_search_dropDown_item_posXpath,
@@ -1277,9 +1287,18 @@ object_http_url_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": urlObjectPage_addItem_posXpath,
+ "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath,
+ "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath,
+ "objectPage_inputItem_posXpath": urlObjectPage_inputItem_posXpath,
+ "objectPage_button_saveItem_posXpath": urlObjectPage_saveItem_posXpath,
+ "objectPage_okButton_posXpath": urlObjectPage_okButton_posXpath,
+ },
"search": {
"objectListPage_searchLabel_posXpath": urlObjectPage_searchLabel_posXpath,
- "objectListPage_searchLabel_selectName_posXpath": urlObjectListPage_searchLabel_selectName_posXpath,
+ "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath,
"objectListPage_tableTbody_posXpath": urlObjectListPage_tableTbody_posXpath,
"objectListPage_search_input_posXpath": urlObjectListPage_search_input_posXpath,
"objectListPage_search_dropDown_item_posXpath": urlObjectListPage_search_dropDown_item_posXpath,
@@ -1313,9 +1332,18 @@ object_account_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": accountobjectPage_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_searchLabel_posXpath": accountObjectPage_searchLabel_posXpath,
- "objectListPage_searchLabel_selectName_posXpath": accountObjectListPage_searchLabel_selectName_posXpath,
+ "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath,
"objectListPage_tableTbody_posXpath": accountObjectListPage_tableTbody_posXpath,
"objectListPage_search_input_posXpath": accountObjectListPage_search_input_posXpath,
"objectListPage_search_dropDown_item_posXpath": accountObjectListPage_search_dropDown_item_posXpath,
diff --git a/support/ui_utils/object/create_objects_example.py b/support/ui_utils/object/create_objects_example.py
index d848fa22a..09a1c958b 100644
--- a/support/ui_utils/object/create_objects_example.py
+++ b/support/ui_utils/object/create_objects_example.py
@@ -25,7 +25,7 @@ class CreateObjects:
# if isinstance(temp_object_configuration, dict):
# object_configuration.append(temp_object_configuration)
code_list = []
- if "and_conditions" in configuration.keys():
+ if isinstance(configuration,dict) and "and_conditions" in configuration.keys():
and_conditions = configuration["and_conditions"]
for i in range(len(and_conditions)):
or_conditions = and_conditions[i]["or_conditions"]
diff --git a/support/ui_utils/object/delete_objects_example.py b/support/ui_utils/object/delete_objects_example.py
index 7ecb073e9..72b83eaef 100644
--- a/support/ui_utils/object/delete_objects_example.py
+++ b/support/ui_utils/object/delete_objects_example.py
@@ -12,12 +12,24 @@ class DeleteObjects:
self.driver = driver
self.driver.implicitly_wait(5)
- def delete(self,object_tuple,first_row_checkbox_element):
+ def delete(self,parmameter,objects_tuple):
try:
- for obj in object_tuple:
- element_position_library = get_element_position(obj["type"])
+ for object in objects_tuple:
+ element_position_library = get_element_position(object["type"])
delete_element_position = element_position_library["delete"]
- first_row_checkbox_element.click()
+ 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(object["uuid"])
+ self.driver.find_element(By.XPATH, search_element_position["objectListPage_searchLabel_selectID_posXpath"]).click()
+ self.driver.find_element(By.XPATH,search_element_position["objectListPage_search_button_posXpath"]).click()
+ time.sleep(2)
+ self.driver.find_element(By.XPATH, '(//input[@aria-label="Select row"])[1]').click()
+ #点击删除按钮
self.driver.find_element(By.XPATH, delete_element_position["objectListPage_deleteButton_posXpath"]).click()
self.driver.find_element(By.XPATH,delete_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click()
time.sleep(3)
diff --git a/support/ui_utils/object/edit_objects_example.py b/support/ui_utils/object/edit_objects_example.py
index 5a2894d27..a5a339e5c 100644
--- a/support/ui_utils/object/edit_objects_example.py
+++ b/support/ui_utils/object/edit_objects_example.py
@@ -8,20 +8,29 @@ from support.ui_utils.object.page_jump import PageJump
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from support.ui_utils.element_position.map_element_position_library import *
-from support.ui_utils.element_position.object_element_position import *
-from datetime import datetime
-
+from support.ui_utils.object.search_objects import SearchObject
class EditObjects:
def __init__(self, driver):
self.driver = driver
- def edit(self, objects_tuple, first_row_checkbox_element,src_item, new_item):
+ def edit(self, objects_tuple,src_item, new_item):
try:
for object in objects_tuple:
element_position_library = get_element_position(object["type"])
+ page_jump_element_position = element_position_library["page_jump"]
edit_element_position = element_position_library["edit"]
- first_row_checkbox_element.click()
+ 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(object["uuid"])
+ self.driver.find_element(By.XPATH, search_element_position["objectListPage_searchLabel_selectID_posXpath"]).click()
+ self.driver.find_element(By.XPATH, search_element_position["objectListPage_search_button_posXpath"]).click()
+ time.sleep(2)
+ self.driver.find_element(By.XPATH,'(//input[@aria-label="Select row"])[1]').click()
self.driver.find_element(By.XPATH, edit_element_position["ObjectListPage_editButton_posXpath"]).click()
object_type = object["type"]
if object_type in ["keyword", "http_signature"]:
@@ -58,33 +67,34 @@ class EditObjects:
elif object_type in ["url", "account", "phone_number", "fqdn", "subscriberid", "apn"]:
if object_type == "phone_number":
self.driver.find_element(By.XPATH,edit_element_position["objectPage_phnoeNumberType_posXpath"]).click()
- for i in range(len(object["items"])): #
+
+ if src_item == "": # 编辑 新增 模式
self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click()
- if object["items"][i]["op"] == "add": # 直接 新增 模式
- if "->" in object["items"][i]["expression"]: # -> 存在,需要拆分
- item_value_str = object["items"][i]["expression"].split("->")[0].strip()
- else: # -> 不存在,直接取值
- item_value_str = object["items"][i]["expression"].strip()
- # 匹配多个multiple substrings 类型
- if "&" in item_value_str: # & 含有多个 and multiple substrings
- item_values = item_value_str.split("&")
- else:
- item_values = [item_value_str]
- else: # 修改模式,未完成
- # print("todo modify moudle ...")
- item_values = [object["items"][i]["item_value"]]
- for j, item_value in enumerate(item_values): # 遍历添加 multi substr,第一个元素不用点击 + 图标
- item_value = item_value.strip()
- if j == 0:
- # 适配24.10 版本,需要逐个字符输入
- input_field = self.driver.find_element(By.XPATH, edit_element_position["objectPage_inputItem_posXpath"])
- for char in str(item_value):
- input_field.send_keys(char)
- time.sleep(0.1)
- else:
- self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_sameItem_addItem_posXpath"]).click()
- self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value)
- self.driver.find_element(By.XPATH,edit_element_position["objectPage_button_saveItem_posXpath"]).click()
+ item_value_str = new_item
+ # 匹配多个multiple substrings 类型
+ if "&" in item_value_str: # & 含有多个 and multiple substrings
+ item_values = item_value_str.split("&")
+ else:
+ item_values = [item_value_str]
+ else: # 修改模式
+ self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_search_item_posXpath"]).send_keys(src_item + Keys.ENTER)
+ self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_edit_item_posXpath"]).click()
+ input_field = self.driver.find_element(By.XPATH, edit_element_position["objectPage_inputItem_posXpath"])
+ input_field.send_keys(Keys.CONTROL, 'a') # 或使用 Keys.COMMAND 在 macOS
+ input_field.send_keys(Keys.DELETE)
+ item_values = [new_item]
+ for j, item_value in enumerate(item_values): # 遍历添加 multi substr,第一个元素不用点击 + 图标
+ item_value = item_value.strip()
+ if j == 0:
+ # 适配24.10 版本,需要逐个字符输入
+ input_field = self.driver.find_element(By.XPATH, edit_element_position["objectPage_inputItem_posXpath"])
+ for char in str(item_value):
+ input_field.send_keys(char)
+ time.sleep(0.1)
+ else:
+ self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_sameItem_addItem_posXpath"]).click()
+ self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value)
+ self.driver.find_element(By.XPATH,edit_element_position["objectPage_button_saveItem_posXpath"]).click()
elif object_type == "flag":
for i in range(len(object["items"])): #
self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click()
diff --git a/support/ui_utils/object/search_objects_example.py b/support/ui_utils/object/search_objects_example.py
index f71ba02a9..edc27542a 100644
--- a/support/ui_utils/object/search_objects_example.py
+++ b/support/ui_utils/object/search_objects_example.py
@@ -17,56 +17,64 @@ class SearchObjects:
self.my_random = RandomName()
+ def search(self,name,policy_configuration,search_type):
+ if "name" != "":
+ self.get_object_uuid(name,policy_configuration)
+ else:
+ self.search_objects(policy_configuration,search_type)
+
- def search(self,object_info,search,element_position_library):
+ def search_objects(self,objects_tuple,search_type):
try:
- page_jump_element_position = element_position_library["page_jump"]
- # 打开该列表
- page_jump = PageJump(self.driver)
- time.sleep(0.5)
- page_jump.jump_sub_object_page(page_jump_element_position)
- search_types = search["type"].split('&')
- for search_type in search_types:
- search_value = self.get_search_value(object_info,search_type,search["is_fuzzy"])
- if search_type == "uuid":
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_Id_posXpath).click()
- elif search_type == "name":
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_Name_posXpath).click()
- elif search_type == "description":
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_Description_posXpath).click()
- elif search_type == "details":
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_Details_posXpath).click()
- elif search_type == "sub_type":
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_subType_posXpath).click()
- elif search_type == 'sub_name':
- # 删除Group下的sub mobile
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_Name_posXpath).click()
- elif search_type == "ip":
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH, objectListPage_search_select_IP_posXpath).click()
- elif "global" in search_type :
- self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
- self.driver.find_element(By.XPATH,listPage_objectSearch_ip_address_select_Search_posXpath).click()
- # self.driver.find_element(By.XPATH, mainPage_objectSearch_buttonSearch_posXpath).click()
- # time.sleep(0.5)
- # row = self.driver.find_elements(By.XPATH, "//div[@class='MuiDataGrid-virtualScrollerContent css-0']/div/div")
- # if len(row) != 0:
- # first_row = row[0]
- # first_row_checkBox_element = first_row.find_element(By.XPATH, '//input[@aria-label="Select row"]')
- return 200
+ for object in objects_tuple:
+ element_position_library = get_element_position(object["type"])
+ page_jump_element_position = element_position_library["page_jump"]
+ # 打开该列表
+ page_jump = PageJump(self.driver)
+ time.sleep(0.5)
+ page_jump.jump_sub_object_page(page_jump_element_position)
+ search_types = search_type["type"].split('&')
+ for search_type in search_types:
+ search_value = self.get_search_value(object, search_type,search_type["is_fuzzy"])
+ if search_type == "uuid":
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_Id_posXpath).click()
+ elif search_type == "name":
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_Name_posXpath).click()
+ elif search_type == "description":
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_Description_posXpath).click()
+ elif search_type == "details":
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_Details_posXpath).click()
+ elif search_type == "sub_type":
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_subType_posXpath).click()
+ elif search_type == 'sub_name':
+ # 删除Group下的sub mobile
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_Name_posXpath).click()
+ elif search_type == "ip":
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).click()
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH, objectListPage_search_select_IP_posXpath).click()
+ elif "global" in search_type :
+ self.driver.find_element(By.XPATH,ipObjectListPage_searchLabel_posXpath).send_keys(search_value)
+ self.driver.find_element(By.XPATH,listPage_objectSearch_ip_address_select_Search_posXpath).click()
+ # self.driver.find_element(By.XPATH, mainPage_objectSearch_buttonSearch_posXpath).click()
+ # time.sleep(0.5)
+ # row = self.driver.find_elements(By.XPATH, "//div[@class='MuiDataGrid-virtualScrollerContent css-0']/div/div")
+ # if len(row) != 0:
+ # first_row = row[0]
+ # first_row_checkBox_element = first_row.find_element(By.XPATH, '//input[@aria-label="Select row"]')
+ return 200
except Exception as e:
raise
@@ -104,11 +112,11 @@ class SearchObjects:
return search_value
- def get_object_info(self,name,object_configuration):
+ def get_object_uuid(self,name,object_configuration):
try:
object_uuids_list = []
object_uuids_temp_dict = {}
- for object in object_configuration["or_conditions"]:
+ for object in object_configuration:
# 获取当前所需的element
if "sub_type" in object.keys():
object_type = object["sub_type"]
@@ -139,10 +147,10 @@ class SearchObjects:
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,200
+ object_uuids_tuple = tuple(object_uuids_list)
+ return object_uuids_tuple,200
except Exception as e:
- raise
+ return 400
def get_first_object(self,uuid,object_configuration):
try:
@@ -168,7 +176,7 @@ class SearchObjects:
if len(row) != 0:
first_row = row[0]
first_row_checkBox_element = first_row.find_element(By.XPATH, '//input[@aria-label="Select row"]')
- return 200, first_row_checkBox_element
+ return first_row_checkBox_element,200
except Exception as e:
raise
# def main_page_item_search(self,object_info):
diff --git a/support/ui_utils/ui_client.py b/support/ui_utils/ui_client.py
index 7a6fcd5e9..1bec8ecdf 100644
--- a/support/ui_utils/ui_client.py
+++ b/support/ui_utils/ui_client.py
@@ -31,21 +31,21 @@ class UIClient:
objects = CreateObjects(self.driver)
code = objects.create_objects(policy_configuration)
return code
-
- def search_objects(self, policy_configuration, search_type):
- objects = SearchObjects()
- objects_tuple, code = objects.search_objects(policy_configuration, search_type)
+
+ def search_objects(self, name, policy_configuration, search_type):
+ objects = SearchObjects(self.driver)
+ objects_tuple, code = objects.get_object_uuid(name, policy_configuration)
self.objects_tuple = objects_tuple
return objects_tuple, code
- def edit_objects(self, objects_tuple, policy_configuration):
- objects = EditObjectsExample()
- code = objects.edit_objects(objects_tuple, policy_configuration, self.driver)
+ def edit_objects(self, objects_tuple, src_item,new_item):
+ objects = EditObjects(self.driver)
+ code = objects.edit(objects_tuple, src_item,new_item)
return code
def delete_objects(self, objects_tuple):
- objects = DeleteObjectsExample(self.driver)
- objects.delete_objects(self.parameter, objects_tuple)
+ objects = DeleteObjects(self.driver)
+ objects.delete(self.parameter, objects_tuple)
def create_rules(self, policy_configuration):
self.policy_configuration = policy_configuration
diff --git a/tests/object/test_temp/create_account_object_temp.py b/tests/object/test_temp/create_account_object_temp.py
index fbaf53c3f..e5023f68c 100644
--- a/tests/object/test_temp/create_account_object_temp.py
+++ b/tests/object/test_temp/create_account_object_temp.py
@@ -16,10 +16,9 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions": [
+ object_configuration = [
{
- "name": "test",
+ "name": "create_account_object",
"type": "account",
"member_type": "item",
"statistics_option": "", # random
@@ -27,46 +26,63 @@ def run(parameter):
{
"op": "add",
"expr_type": "and",
- "expression": "[email protected]&abcd"
+ "expression": "[email protected]"
}
]
}
- ],
- # "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_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 ")
+
+ # 编辑
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item="user")
+ 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 ")
+ code = ui_client.edit_objects(objects_tuple, src_item="[email protected]", new_item="ftpuser")
+ 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)
return "When running test case, the exception error: " + str(e)
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)
+
# 生成csv报告
update = ReportUpdate()
update.write_result(parameter, result, exception_result)
diff --git a/tests/object/test_temp/create_fqdn_object_temp.py b/tests/object/test_temp/create_fqdn_object_temp.py
index 1108859df..2d35a55eb 100644
--- a/tests/object/test_temp/create_fqdn_object_temp.py
+++ b/tests/object/test_temp/create_fqdn_object_temp.py
@@ -16,40 +16,62 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions": [
- {
- "name": "test",
- "type": "fqdn",
- "member_type": "item",
- "statistics_option": "", # random
- "items": [
- {
- "op": "add",
- "expr_type": "and",
- "expression": "open.node.com"
- },
- ],
- }
- ],
- "search": {
- "is_fuzzy": False,
- "type": "uuid"
- },
- "audit_log": False # system
- }
+ object_configuration = [
+ {
+ "name": "create_fqdn_object",
+ "type": "fqdn",
+ "member_type": "item",
+ "statistics_option": "", # random
+ "items": [
+ {
+ "op": "add",
+ "expr_type": "and",
+ "expression": "open.node.com"
+ },
+ ]
+ }
+ ]
+
+ 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_fqdn_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_item是空,则表示该item是新加
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item="baidu.com")
+ 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="open.node.com", new_item="^www.youtube.com$")
+ 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)
@@ -57,15 +79,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
@@ -73,6 +90,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_ip_learning_objects_temp.py b/tests/object/test_temp/create_ip_learning_objects_temp.py
index 241716d3f..ec4499dbf 100644
--- a/tests/object/test_temp/create_ip_learning_objects_temp.py
+++ b/tests/object/test_temp/create_ip_learning_objects_temp.py
@@ -16,46 +16,49 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions": [
- {
- "name": "test",
- "type": "ip",
- "op": "add",
- "sub_type": "ip_learning",
- "member_type": "item",
- "statistics_option": "", # random
- "learning_plan": {
- "fqdn_ip_learning_plan": {
- "learning_depth": "1",
- "from_protocol": "SSL",
- "aging_time": 10,
- "vote_client_num": 10,
- "goal_upper_limit": 10,
- "from_fqdns": [
- "^www.example.com$"
- ]
- }
+ object_configuration = [
+ {
+ "name": "create_ip_learing_object",
+ "type": "ip",
+ "op": "add",
+ "sub_type": "ip_learning",
+ "member_type": "item",
+ "statistics_option": "", # random
+ "learning_plan": {
+ "fqdn_ip_learning_plan": {
+ "learning_depth": "1",
+ "from_protocol": "SSL",
+ "aging_time": 10,
+ "vote_client_num": 10,
+ "goal_upper_limit": 10,
+ "from_fqdns": [
+ "^www.example.com$"
+ ]
}
}
- ],
- "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 ")
+
+ # 查询
+ objects_tuple, code = ui_client.search_objects("create_ip_learing_object", object_configuration, "")
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 ")
+ return ""
except Exception as e:
exception_result = str(e)
@@ -64,15 +67,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
@@ -80,6 +78,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_ip_object_temp.py b/tests/object/test_temp/create_ip_object_temp.py
index ff822e12f..3c0312afe 100644
--- a/tests/object/test_temp/create_ip_object_temp.py
+++ b/tests/object/test_temp/create_ip_object_temp.py
@@ -15,56 +15,64 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions": [
- {
- "name": "create_ip_object",
- "type": "ip",
- "sub_type": "ip",
- "member_type": "item",
- "statistics_option": "", # random
- "items": [
- {
- "op": "add",
- "ip": "1.1.1.1",
- "interval": "0-65535"
- },
- {
- "op": "add",
- "ip": "192.168.2.1/24",
- "interval": "0-65535"
- }
- ]
- },
- ]
- }
+ object_configuration = [
+ {
+ "name": "create_ip_object",
+ "type": "ip",
+ "sub_type": "ip",
+ "member_type": "item",
+ "statistics_option": "", # random
+ "items": [
+ {
+ "op": "add",
+ "ip": "1.1.1.1",
+ "interval": "0-65535"
+ },
+ {
+ "op": "add",
+ "ip": "192.168.2.1/24",
+ "interval": "0-65535"
+ }
+ ]
+ }
+ ]
- ui_client = UIClient()
+ ui_client = UIClient(parameter)
# 创建
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_ip_object",object_configuration,type="object_info")
+ objects_tuple, code = ui_client.search_objects("create_ip_object",object_configuration,search_type)
objects_list = list(objects_tuple)
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 ")
# 编辑
- object_uuid = objects_tuple[0]["uuid"]
- first_row_checkbox_element,result = ui_client.search_objects(object_uuid,object_configuration,type="object_select")
# 如果src_item是空,则表示该item是新加
- code = ui_client.edit_objects(objects_tuple,first_row_checkbox_element, src_item="", new_item="3.3.3.3")
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item="3.3.3.3")
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,first_row_checkbox_element, src_item="1.1.1.1", new_item="2.2.2.2")
+ code = ui_client.edit_objects(objects_tuple, src_item="1.1.1.1", new_item="2.2.2.2")
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:
@@ -74,8 +82,9 @@ def run(parameter):
finally:
# 删除
if objects_tuple:
- ui_client.delete_objects( objects_tuple,first_row_checkbox_element)
-
+ 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
diff --git a/tests/object/test_temp/create_url_object_temp.py b/tests/object/test_temp/create_url_object_temp.py
index c91450eb4..8d661c3f7 100644
--- a/tests/object/test_temp/create_url_object_temp.py
+++ b/tests/object/test_temp/create_url_object_temp.py
@@ -16,39 +16,60 @@ def run(parameter):
script_start_time = time.time()
#测试数据
- object_configuration = {
- "or_conditions": [
- {
- "name": "test",
- "type": "url",
- "member_type": "item",
- "statistics_option": "", # random
- "items": [
- {
- "op": "add",
- "expr_type": "and",
- "expression": "english&abcd"
- }
- ]
- }
- ],
- "search": {
- "is_fuzzy": False,
- "type": "uuid"
- },
- "audit_log": False # system
- }
+ object_configuration = [
+ {
+ "name": "create_url_object",
+ "type": "url",
+ "member_type": "item",
+ "statistics_option": "", # random
+ "items": [
+ {
+ "op": "add",
+ "expr_type": "and",
+ "expression": "english"
+ }
+ ]
+ }
+ ]
+
+ 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_url_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_item是空,则表示该item是新加
+ code = ui_client.edit_objects(objects_tuple, src_item="", new_item="facebook")
+ 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="english", new_item="baidu")
+ 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)
@@ -56,15 +77,11 @@ 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
@@ -72,6 +89,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)