diff options
Diffstat (limited to 'common/ui_common')
| -rw-r--r-- | common/ui_common/objects/accounts.py | 346 | ||||
| -rw-r--r-- | common/ui_common/objects/intervals.py | 6 | ||||
| -rw-r--r-- | common/ui_common/objects/objects_public_operations.py | 77 | ||||
| -rw-r--r-- | common/ui_common/objects/tunnels.py | 215 |
4 files changed, 430 insertions, 214 deletions
diff --git a/common/ui_common/objects/accounts.py b/common/ui_common/objects/accounts.py index fd09d4f2..17942673 100644 --- a/common/ui_common/objects/accounts.py +++ b/common/ui_common/objects/accounts.py @@ -1,5 +1,6 @@ # -*- coding: UTF-8 -*- import configparser +import re import time import pytest @@ -76,6 +77,7 @@ class Accounts: self.driver.find_element(By.XPATH, mainPage_firstLevelMenu_Objects_posXpath).click() self.driver.implicitly_wait(2) self.driver.find_element(By.XPATH, mainPage_secondLevelMenu_Account_posXpath).click() + time.sleep(3) @screenshot_on_failure def _just_goto_accountsPage(self): @@ -101,6 +103,7 @@ class Accounts: is_first_exist = self.driver.element_isExist(By.XPATH, list_first_row_first_column_posXpath) assert is_first_exist or total_value == 0, "校验失败!!列表页为空!!" self.my_count += 1 + time.sleep(3) @screenshot_on_failure def _create(self, data): @@ -343,7 +346,7 @@ class Accounts: if data_acc == "[random]": data_acc = self.random_account self._items_acc_add(data_acc) - self._items_acc_search(search_pos="single", search_value=data_acc) + # self._items_acc_search(search_pos="single", search_value=data_acc) elif data_acc[-16:] == "[ImportFromFile]": # abc.txt[ImportFromFile]->表示文件导入方式添加Item data_file_name = data_acc[:-16] self._items_acc_add_from_file(data_file_name) @@ -354,7 +357,7 @@ class Accounts: item_datas = f.readlines() # 读取文件所有行内容 item_data = item_datas[random.randint(1, len(item_datas)) - 1].replace("\\n", "").strip() # 任选一行的数据 - self._items_acc_search(search_pos="single", search_value=item_data) + # self._items_acc_search(search_pos="single", search_value=item_data) elif "&" in data_values[i].split("->")[0].strip(): # 一条Item中加多个数据: # print("#一条Item中加多个数据") item_value_list = [] @@ -423,8 +426,9 @@ class Accounts: data_acc = self.my_random.random_account() self._operate_sub_items_modify(data, old_data, data_acc) if search_sub_obj: - self._items_acc_search(search_pos="sub", - search_value=self._operate_sub_name(data, data_acc)) + pass + # self._items_acc_search(search_pos="sub", + # search_value=self._operate_sub_name(data, data_acc)) else: # 新增数据 asdnkj-> if data_acc == "[random]": # random->表示新增对象value值为随机 data_acc = self.random_account @@ -436,8 +440,9 @@ class Accounts: else: self._sub_objects_acc_add(data, data_acc) if search_sub_obj: - self._items_acc_search(search_pos="sub", - search_value=self._operate_sub_name(data, data_acc)) + pass + # self._items_acc_search(search_pos="sub", + # search_value=self._operate_sub_name(data, data_acc)) @screenshot_on_failure def _items_acc_del(self, item_value): @@ -544,7 +549,7 @@ class Accounts: # # print("加载完毕") # break self.first_row_checkBox_element = self.driver.find_element(By.XPATH,listPage_select_first_object_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # return item_data @screenshot_on_failure @@ -609,9 +614,8 @@ class Accounts: # self.driver.isElementExist('//div[@class="EditDraw"]//div[@class="el-loading-mask"]') # if not self.driver.Exist: # break - self.driver.find_element(By.XPATH, '//div[@data-desc="exclude subObject"]/label').click() # 判断 Exclude Objects 按钮是否处于开启状态 - if self.driver.element_isExist(By.XPATH, urlGroup_ObjectDetailPage_excludeObjectsSwitch_enableStatus_posXpath): + if self.driver.element_isExist(By.XPATH, accGroup_ObjectDetailPage_excludeObjectsSwitch_enableStatus_posXpath): print("有数据新建") # 点击Exclude Objects 下的"+"按钮 self.driver.find_element(By.XPATH, @@ -643,10 +647,10 @@ class Accounts: # 点击侧滑子Create Account页面中Items下的"+"按钮 self.driver.find_element(By.XPATH, acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_itemsAddButton_posXpath).click() + for i in item_value: # 于侧滑子Create Account页面中Items下的item value输入框键入 item_value - self.driver.find_element(By.XPATH, - acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_itemsValueInput_posXpath).send_keys( - item_value) + self.driver.find_element(By.XPATH, + acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_itemsValueInput_posXpath).send_keys(i) # 点击侧滑子Create Account页面中Items下的保存按钮 self.driver.find_element(By.XPATH, acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_itemsValueSaveButton_posXpath).click() @@ -663,7 +667,8 @@ class Accounts: acc_item_input_xpath = "//input[@value='{}']".format(old_value) self.driver.find_element(By.XPATH, acc_item_input_xpath).clear() # 清空后键入新数据 - self.driver.find_element(By.XPATH, acc_item_input_xpath).send_keys(new_value) + for i in new_value: + self.driver.find_element(By.XPATH, acc_item_input_xpath).send_keys(i) # 保存 acc_item_save_btn_xpath = acc_ObjectDetailPage_itemSaveButton_poXpath self.driver.find_element(By.XPATH, acc_item_save_btn_xpath).click() @@ -675,8 +680,8 @@ class Accounts: self.driver.find_element(By.XPATH, acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_okButton_posXpath).click() # 点击确认弹窗的YES - self.driver.find_element(By.XPATH, - acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_okButton_yes_posXpath).click() + # self.driver.find_element(By.XPATH, + # acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_okButton_yes_posXpath).click() def _operate_exclude_items_modify(self, data, old_value, new_value): self._exclude_items_acc_modify(data, old_value, new_value) @@ -692,23 +697,23 @@ class Accounts: my_sub_item_name = self._operate_sub_name(data, old_value) time.sleep(0.5) # 点击要修改数据的编辑按钮操作 - sub_acc_object_edit_btn_xpath = "(//*[normalize-space(text())='{}']/ancestor::li[contains(@class,'item margindouble')]//i[contains(@class,'icon-Edit')])[1]".format( + sub_acc_object_edit_btn_xpath = "(//*[normalize-space(text())='{}']/ancestor::li[contains(@class,'list-none truncate relative')]//i[contains(@class,'icon-Edit')])[1]".format( my_sub_item_name) print("my_sub_item_name:{}".format(my_sub_item_name)) self.driver.find_element(By.XPATH, sub_acc_object_edit_btn_xpath).click() print("clicked sub_acc_object_edit_btn") # 进入Edit Interval侧滑页面 # 点击要修改数据的编辑按钮操作 - sub_acc_item_edit_btn_xpath = "(//*[normalize-space(text())='{}']/ancestor::*[@class='view-row']//i[contains(@class, 'iconfont icon-Edit')])[1]".format( - old_value) + sub_acc_item_edit_btn_xpath = '//div[@class="items"]//i[@class="iconfont icon-Edit"]' print("old_value:{}".format(old_value)) self.driver.implicitly_wait(6) self.driver.find_element(By.XPATH, sub_acc_item_edit_btn_xpath).click() # 清空要编辑修改数据的输入框内容 - sub_acc_item_input_xpath = '//div[@exprlistdata="{}"]//input'.format(old_value) + sub_acc_item_input_xpath = '//input[@class="MuiInput-input css-1u0jcuo"]' self.driver.find_element(By.XPATH, sub_acc_item_input_xpath).clear() # 清空后键入新数据 - self.driver.find_element(By.XPATH, sub_acc_item_input_xpath).send_keys(new_value) + for i in new_value: + self.driver.find_element(By.XPATH, sub_acc_item_input_xpath).send_keys(i) # 保存 sub_acc_item_save_btn_xpath = acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_itemsValueSaveButton_posXpath self.driver.find_element(By.XPATH, sub_acc_item_save_btn_xpath).click() @@ -718,7 +723,7 @@ class Accounts: my_exclude_item_name = self._operate_exclude_name(data, old_value) time.sleep(0.5) # 点击要修改数据的编辑按钮操作 - exclude_acc_object_edit_btn_xpath = "(//div[@data-desc='exclude subObject']//*[normalize-space(text())='{}']/ancestor::li[contains(@class,'item margindouble')]//i[contains(@class,'icon-Edit')])[1]".format( + exclude_acc_object_edit_btn_xpath = "(//*[normalize-space(text())='{}']/ancestor::li[contains(@class,'list-none truncate relative')]//i[contains(@class,'icon-Edit')])[1]".format( my_exclude_item_name) # print("my_sub_item_name:{}".format(my_exclude_item_name)) self.driver.find_element(By.XPATH, exclude_acc_object_edit_btn_xpath).click() @@ -731,10 +736,11 @@ class Accounts: self.driver.implicitly_wait(6) self.driver.find_element(By.XPATH, exclude_acc_item_edit_btn_xpath).click() # 清空要编辑修改数据的输入框内容 - exclude_acc_item_input_xpath = '//div[@exprlistdata="{}"]//input'.format(old_value) + exclude_acc_item_input_xpath = '//input[@class="MuiInput-input css-1u0jcuo"]' self.driver.find_element(By.XPATH, exclude_acc_item_input_xpath).clear() # 清空后键入新数据 - self.driver.find_element(By.XPATH, exclude_acc_item_input_xpath).send_keys(new_value) + for i in new_value: + self.driver.find_element(By.XPATH, exclude_acc_item_input_xpath).send_keys(i) # 保存 exclude_acc_item_save_btn_xpath = acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_itemsValueSaveButton_posXpath self.driver.find_element(By.XPATH, exclude_acc_item_save_btn_xpath).click() @@ -880,6 +886,7 @@ class Accounts: # 点击侧滑子Create Account页面中OK按钮 self.driver.find_element(By.XPATH, acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_okButton_posXpath).click() # 点击“OK”按钮 + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() # 点击侧滑子Create Account页面确认弹窗的“Yes”按钮 # subCreateAccountDrawer_okButton_yes = self.driver.find_element(By.XPATH, # acc_ObjectGroupDetailPage_subObjects_subCreateAccountDrawer_okButton_yes_posXpath) @@ -929,8 +936,9 @@ class Accounts: data_acc = self.my_random.random_account() self._operate_exclude_items_modify(data, old_data, data_acc) if search_exclude_obj: - self._items_acc_search(search_pos="exclude", - search_value=self._operate_sub_name(data, data_acc)) + pass + # self._items_acc_search(search_pos="exclude", + # search_value=self._operate_sub_name(data, data_acc)) else: # 新增数据 asdnkj-> if data_acc == "[random]": # random->表示新增对象value值为随机 # if data_values[i].split("->")[0].strip() == "[random]": @@ -944,8 +952,9 @@ class Accounts: else: self._exclude_sub_objects_acc_add(data, data_acc) if search_exclude_obj: - self._items_acc_search(search_pos="exclude", - search_value=self._operate_sub_name(data, data_acc)) + pass + # self._items_acc_search(search_pos="exclude", + # search_value=self._operate_sub_name(data, data_acc)) @screenshot_on_failure def _query(self, data, search_type="Name", search_value=None, **kwargs): @@ -1076,6 +1085,7 @@ class Accounts: self.objects_po.clear_name_by_id(acc_objects_search_input_posXpath) if fuzzy_search: # 随机方式全局模糊搜索 acc_objects_search_input_elem.send_keys(search_value) # 键入搜索值 + self.driver.find_element(By.XPATH, listpage_globalSearch_posXpath).click() random_enter = random.randint(0, 1) # random_enter = 1 if random_enter == 0: # 使用ENTER 确认搜索值 @@ -1084,14 +1094,14 @@ class Accounts: acc_objects_search_input_elem.send_keys(Keys.ENTER) # 确认输入框内容 else: # 鼠标点击确认搜索值 print("随机全局模糊搜索-Mouse Click") - self.driver.find_element(By.XPATH, acc_listPage_object_fuzzySearch_posXpath).click() # 点击搜索按钮 + self.driver.find_element(By.XPATH, listpage_search_button_posXpath).click() # 点击搜索按钮 else: # 精确属性的搜索 acc_objects_search_input_elem.send_keys(search_value) time.sleep(1) if search_type == "Name" or search_type == "": self.driver.find_element(By.XPATH, acc_listPage_object_searchName_posId).click() - elif search_type == "ID": - self.driver.find_element(By.XPATH, acc_listPage_object_searchId_posId).click() + elif search_type == "UUID": + self.driver.find_element(By.XPATH, listPage_objectSearch_select_UUID_posXpath).click() elif search_type == "Details": self.driver.find_element(By.XPATH, acc_listPage_object_searchDetails_posId).click() elif search_type == "Description": @@ -1137,8 +1147,8 @@ class Accounts: else: # 勾选第一行元素 self.first_row_checkBox_element = self.driver.find_element(By.XPATH, - acc_listPage_first_row_checkBox_posXpath).click() - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 解析修改数据 self._operate_page(data, operation_type="edit", no_modify=False) # 进入Object详情页 @@ -1177,6 +1187,7 @@ class Accounts: acc_listPage_object_urls_delete_noButton_posXpath) # 删除object group对象后,再删除子object对象 while del_count > 0: + self.go_to_page() print("del 循环") try: if del_flag: @@ -1294,13 +1305,14 @@ class Accounts: self._create(data) # 新建 self._query(data) # 创建后查询 # 勾选被引用的对象 - first_quoted_object_elem_posXpath = "(//div[@data-field='reference_count']/button[number(text())=1]/../..//input[@class='MuiCheckbox-input css-1jj0cvj'])[1]" # 引用数大于0的第一个对象对应的勾选框元素Xpath - first_quoted_object_elem = self.driver.find_element(By.XPATH,first_quoted_object_elem_posXpath) # 引用数大于0的第一个对象对应的勾选框元素 + first_quoted_object_elem_posXpath = listpage_select_second_object_posXpath # 引用数大于0的第一个对象对应的勾选框元素Xpath + first_quoted_object_elem = self.driver.find_element(By.XPATH, + first_quoted_object_elem_posXpath) # 引用数大于0的第一个对象对应的勾选框元素 first_quoted_object_elem.click() # 点击勾选框 # 定位删除按钮元素,并判断是否可点击 - del_button_elem_clickable = self.objects_po.is_element_clickable(acc_listPage_deleteButton_posXpath, "XPATH") + del_button_elem_clickable = self.objects_po.is_element_clickable(listpage_delete_button_posXpath, "XPATH") print("当前元素是否可点击:{}".format(del_button_elem_clickable)) - assert del_button_elem_clickable == False, "校验失败!此时删除按钮可点击!" + assert del_button_elem_clickable == False, "校验删除按钮不可点击" @screenshot_on_failure def _reference_count(self): @@ -1462,6 +1474,76 @@ class Accounts: self.objects_po.Column_ele_ex(Column_text=self.objects_po.Column_text) assert self.objects_po.result + def export_multi_condition_test(self,data): + self.create(data) # 新建,新建后就是查询到该条数据的状态 + if data["SubType"] == "cancel_export": + #1、单个Object导出取消选中目标数据 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.pop_cancel_export_num() + self.create(data) + # 2、多个Object导出取消选中目标数据(2个) + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, listpage_select_second_object_posXpath).click() + self.pop_cancel_export_num() + self._del(data) + elif data["SubType"] == "multi_export": + if data["multi_type"] == "all":#4、多选导出所有数据,校验行数 + self.create(data) + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, listpage_select_second_object_posXpath).click() + self._export_objects1() + assert self.export_number == 2,"断言多选全部导出是否符合预期" + self._del(data) + elif data["multi_type"] == "part":#3、多选导出第一个数据 + self.create(data) + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, listpage_select_second_object_posXpath).click() + self.pop_export_part() + assert self.export_number == 1,"断言单选导出数据是否符合预期" + time.sleep(2) + self.driver.refresh() + self._del(data) + else: #多选数据中有group时无法导出 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, listpage_select_second_object_posXpath).click() + #self.driver.find_element(By.XPATH,listPage_object_apns_exportButton_posXpath).click() + status = self.driver.isElementExist(Element='//span[@class="action-export inline-flex mr-[8px] "]//button[contains(@class, "disabled")]') + assert status == True + # export_tip = self.driver.find_element(By.XPATH,'//div[@class="el-message el-message--error"]/p').text + # assert export_tip.strip() == "Object group is not exportable" + self._del(data) + + + def pop_export_part(self): + self.driver.find_element(By.XPATH, listpage_export_button_posXpath).click() + self.driver.find_element(By.XPATH, '//div[@role="dialog"]//div[@data-rowindex="0"]//input').click() # 选择第一个 + self.export_total_str = self.driver.find_element(By.XPATH,'//div[@class="text-center color-[--color-text] mt-[12px] MuiBox-root css-0"]').text # 定位到导出个数的按钮 + self.export_total = re.search(r'\d+', self.export_total_str) # 正则表达式返回匹配的数字对象 + if self.export_total: + self.export_number = int(self.export_total.group()) # group()方法返回正则表达式匹配的字符串 + print(self.export_number) + + def pop_cancel_export_num(self): + self.driver.find_element(By.XPATH, listpage_export_button_posXpath).click() + self.driver.isElementExist(Element=port_listPage_object_exportPopYes_posXpath) + assert self.driver.Exist, "断言导出按钮是否置灰不展示" + self.driver.find_element(By.XPATH, listpage_export_no_button_posXpath).click() + self.driver.refresh() + + def _export_objects1(self): + self.driver.find_element(By.XPATH, listpage_export_button_posXpath).click() + time.sleep(3) + self.export_total_str = self.driver.find_element(By.XPATH,'//div[@class="text-center color-[--color-text] mt-[12px] MuiBox-root css-0"]').text + self.driver.find_element(By.XPATH, listPage_object_urls_exportPopYes_posXpath).click() + print(11111) + self.export_total =re.search(r'\d+',self.export_total_str) #正则表达式返回匹配的数字对象 + print(self.export_total_str) + print(2222) + print(self.export_total) + if self.export_total: + self.export_number = int(self.export_total.group())#group()方法返回正则表达式匹配的字符串 + print(self.export_number) + @screenshot_on_failure def _export_objects_and_verify(self, data): self._create(data) # 新建 @@ -1493,7 +1575,7 @@ class Accounts: :return: """ self.driver.implicitly_wait(5) - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() self.driver.find_element(By.XPATH, acc_listPage_object_exportButton_posXpath).click() self.driver.find_element(By.XPATH, acc_listPage_object_exportPopYes_posXpath).click() @@ -1528,8 +1610,8 @@ class Accounts: self._create(data) # 新建 self._query(data, need_verify_details=0) # 创建后查询 # 选中并进入编辑页面 - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 点击Audit Logs self.driver.find_element(By.XPATH, acc_ObjectDetailPage_auditLogs_posXpath).click() self.driver.find_element(By.XPATH, @@ -1550,8 +1632,8 @@ class Accounts: # 修改 self._query(data, need_verify_details=0) # 查询 - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 解析修改数据 self._operate_page(data, operation_type="edit") # 点击ok @@ -1561,8 +1643,8 @@ class Accounts: # self.driver.find_element(By.XPATH, acc_ObjectDetailPage_okButton_yes_posXpath).click() # 点击确认弹窗的“Yes”按钮 # print("保存") # 重新进入对象详情页查看audit logs - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 self.driver.find_element(By.XPATH, acc_ObjectDetailPage_auditLogs_posXpath).click() # 点击Audit Logs self.driver.find_element(By.XPATH, acc_ObjectDetailPage_auditLogsDrawer_firstRowLog_checkBox_posXpath).click() # 勾选第一行log CheckBox @@ -1594,14 +1676,14 @@ class Accounts: try: self._query(data, need_verify_details=0) # 创建后查询 # 选中并进入编辑页面 - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 校验Audit Logs self.objects_po.audit_log_check("Account Object", "Create") # 修改 self._query(data, need_verify_details=0) # 查询 - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 解析修改数据 self._operate_page(data, operation_type="edit") # 点击ok @@ -1609,8 +1691,8 @@ class Accounts: # self.driver.find_element(By.XPATH, acc_ObjectDetailPage_okButton_yes_posXpath).click() # 点击确认弹窗的“Yes”按钮 # print("保存") # 重新进入对象详情页查看audit logs - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 校验Audit Logs self.objects_po.audit_log_check("Account Object", "Edit") except Exception as e: @@ -1623,8 +1705,8 @@ class Accounts: def _verify_items_total(self, data): self._create(data) # 新建 self._query(data) # 创建后查询 - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 # 进入编辑页面 items_total = self.driver.find_element(By.XPATH, acc_ObjectDetailPage_itemsTotal_posXpath).text # Total 值 @@ -2036,13 +2118,13 @@ class Accounts: self._create(data) # 编辑对象,并编辑item self._query(data, need_verify_details=0) # 搜索 - self.first_row_checkBox_element = self.driver.find_element(By.XPATH,acc_listPage_first_row_checkBox_posXpath).click() # 勾选第一行元素 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.first_row_checkBox_element = self.driver.find_element(By.XPATH,listPage_select_first_object_posXpath).click() # 勾选第一行元素 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 item_data = data["Items"][0] if item_data == "[random]": item_data = self.random_account - acc_item_edit_btn_xpath = "(//*[normalize-space(text())='{acc}']/ancestor::*[@class='view-row']//i[contains(@class, 'iconfont icon-Edit')])[1]".format(acc=item_data) + acc_item_edit_btn_xpath = "(//*[normalize-space(text())='{acc}']/ancestor::*[@class='css-103las5']//i[contains(@class, 'iconfont icon-Edit')])[1]".format(acc=item_data) self.driver.find_element(By.XPATH, acc_item_edit_btn_xpath).click() # 点击要修改数据的编辑按钮操作 # 校验此时ImportFromFile按钮不可点击 try: @@ -2188,7 +2270,7 @@ class Accounts: try: assert exclude_objects_switch_elem.get_attribute( - "class") == "el-switch is-checked", "Exclude Objects Switch未被开启!!" + "class") == "MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked Mui-checked css-y2jqxi", "Exclude Objects Switch未被开启!!" print("Exclude Objects Switch成功开启") self.driver.isElementExist(accGroup_ObjectDetailPage_excludeObjects_itemsArea_posXpath) assert self.driver.Exist, "Exclude Objects未开启!!" @@ -2200,7 +2282,7 @@ class Accounts: exclude_objects_switch_elem.click() # 从开启到关闭 try: assert exclude_objects_switch_elem.get_attribute( - "class") == "el-switch", "Exclude Objects Switch未被关闭!!" + "class") == "MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary css-y2jqxi", "Exclude Objects Switch未被关闭!!" print("Exclude Objects Switch成功关闭") self.driver.isElementExist(accGroup_ObjectDetailPage_excludeObjects_itemsArea_posXpath) assert not self.driver.Exist, "Exclude Objects未关闭!!" @@ -2217,10 +2299,10 @@ class Accounts: ###捕获error messages并校验 try: # self.driver.find_element(By.XPATH,acc_ObjectDetailPage_mainOkButton_posXpath).click() # 再次点击OK - error_message = self.driver.find_element(By.XPATH, '//*[@role="alert"]//p').text + error_message = self.driver.find_element(By.XPATH, '//div[@class="account-object-included_sub_object_uuids"]/div[2]').text print(error_message) # assert error_message == "Subordinate objects of an object cannot contain only excluded objects", "error_message 校验失败" - assert error_message in "Subordinate objects of an object cannot be null", "error_message 校验失败" + assert error_message in "Subordinate Objects cannot be empty", "error_message 校验失败" except Exception as e: print(e) raise @@ -2257,13 +2339,14 @@ class Accounts: try: time.sleep(3) self.driver.find_element(By.XPATH,acc_ObjectDetailPage_mainOkButton_posXpath).click() # 再次点击OK - error_message = self.driver.find_element(By.XPATH, '//*[@role="alert"]//p').text + error_message = self.driver.find_element(By.XPATH, '//div[@class="account-object-included_sub_object_uuids"]/div[2]').text print(error_message) # assert error_message == "Subordinate objects of an object cannot contain only excluded objects", "error_message 校验失败" - assert error_message in "Subordinate objects of an object cannot contain only excluded objects", "error_message 校验失败" + assert error_message in "Subordinate Objects cannot be empty", "error_message 校验失败" except Exception as e: print(e) raise + self._del(data) @screenshot_on_failure def _choose_single_object_method(self): @@ -2420,11 +2503,11 @@ class Accounts: if detail_type == 0: # Object详情页 # 选中第一个Object并进入其详情页 self.driver.find_element(By.XPATH, acc_listPage_object_tableCheckbox_firstSingleObject_posXpath).click() - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 elif detail_type == 1: # Object Group详情页 # 选中第一个Object Group并进入其详情页 self.driver.find_element(By.XPATH, acc_listPage_object_tableCheckbox_firstObjectGroup_posXpath).click() - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 else: # etail_type=2--非本Vsys的Object详情页 # 判断当前页有无非本Vsys的对象 @@ -2483,7 +2566,7 @@ class Accounts: # 选中第一个非本Vsys的Object Group或Object并进入其详情页 self.driver.find_element(By.XPATH, acc_listPage_object_tableCheckbox_firstNotLocalVsys_objectOrGroup_posXpath).click() - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # 点击edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # 点击edit按钮 @screenshot_on_failure def _pure_operate_checkbox(self, selected_object_type, selected_objects_number): @@ -2790,7 +2873,7 @@ class Accounts: self._just_goto_accountsPage() self._create(data) self._simple_query(data, data["Name"]) - self.objects_po.View_statistics(edit_element=acc_listPage_editButton_posXpath) + self.objects_po.View_statistics(edit_element=listpage_edit_button_posXpath) except Exception as e: raise e finally: @@ -2924,13 +3007,13 @@ class Accounts: self._just_goto_accountsPage() # 查询object self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(Sou_ID_list[0]) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(2) # 修改数据 if data["Type"] == 0: self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 第一行数据前的复选框 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # edit按钮 self.objects_po.clear_Name(path=ObjectDetailPage_input_Name_posXpath) # 清除name self.driver.find_element(By.XPATH, ObjectDetailPage_input_Name_posXpath).send_keys( data["modify_sou_name"]) # 重新输入name @@ -2943,7 +3026,7 @@ class Accounts: self.driver.find_element(By.XPATH, ObjectDetailPage_okButton_yes_posXpath).click() else: self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 第一行数据前的复选框 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # edit按钮 self.objects_po.clear_Name(path=ObjectDetailPage_input_Name_posXpath) # 清除name self.driver.find_element(By.XPATH, ObjectDetailPage_input_Name_posXpath).send_keys( data["modify_sou_name"]) # 重新输入name @@ -2962,7 +3045,7 @@ class Accounts: self._just_goto_accountsPage() # 查询object self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(Sou_ID_list[0]) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(2) # 获取修改后的数据 @@ -3021,7 +3104,7 @@ class Accounts: self._just_goto_accountsPage() # 搜索目的vsys数据 self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(Des_ID_list[0]) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(2) # 获取sync后的值 @@ -3034,7 +3117,7 @@ class Accounts: # 在目的vsys中修改 if data["Type"] == 0: self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 第一行数据前的复选框 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # edit按钮 self.objects_po.clear_Name(path=ObjectDetailPage_input_Name_posXpath) # 清除name self.driver.find_element(By.XPATH, ObjectDetailPage_input_Name_posXpath).send_keys( data["modify_des_name"]) # 重新输入name @@ -3047,7 +3130,7 @@ class Accounts: self.driver.find_element(By.XPATH, ObjectDetailPage_okButton_yes_posXpath).click() else: self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 第一行数据前的复选框 - self.driver.find_element(By.XPATH, acc_listPage_editButton_posXpath).click() # edit按钮 + self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() # edit按钮 self.objects_po.clear_Name(path=ObjectDetailPage_input_Name_posXpath) # 清除name self.driver.find_element(By.XPATH, ObjectDetailPage_input_Name_posXpath).send_keys( data["modify_des_name"]) # 重新输入name @@ -3077,7 +3160,7 @@ class Accounts: self._just_goto_accountsPage() # 搜索目的vsys数据 self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(Des_ID_list[0]) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(2) # 再次获取sync后的值 @@ -3093,7 +3176,7 @@ class Accounts: def _delete_des(self, Des_ID_list, data): if data["Type"] == 0: self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(Des_ID_list[0]) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(1) self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 选择第一个对象 @@ -3103,7 +3186,7 @@ class Accounts: else: for id in Des_ID_list: self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(id) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(1) self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 选择第一个对象 @@ -3127,7 +3210,7 @@ class Accounts: def _delete_source(self, Sou_ID_list, data): if data["Type"] == 0: self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(Sou_ID_list[0]) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(1) self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 选择第一个对象 @@ -3137,7 +3220,7 @@ class Accounts: else: for id in Sou_ID_list: self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(id) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(1) self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 选择第一个对象 @@ -3215,7 +3298,7 @@ class Accounts: self._just_goto_accountsPage() for id in Des_ID_list: self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(id) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 选择第一个对象 # 确认删除 @@ -3228,7 +3311,7 @@ class Accounts: self._just_goto_accountsPage() for id in Sou_ID_list: self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(id) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + self.driver.find_element(By.ID, listPage_objectSearch_select_UUID_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() time.sleep(1) self.driver.find_element(By.XPATH, listPage_first_row_checkBox_posXpath).click() # 选择第一个对象 @@ -3276,7 +3359,7 @@ class Accounts: search_value = self.my_sub_item_name # 进入drawer_search页面 ##勾选 - self.driver.find_element(By.XPATH, acc_listPage_first_row_checkBox_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() ##点击编辑按钮 self.driver.find_element(By.XPATH, listpage_edit_button_posXpath).click() ##点击 add button展开drawer_search @@ -3287,7 +3370,7 @@ class Accounts: self.driver.find_element(By.XPATH, groupObjectDetailPage_addSubObjecDrawer_searchInput_posXpath).send_keys(self.my_random.random_number() + Keys.ENTER) assert self.driver.find_element(By.XPATH,groupObjectDetailPage_addSubObjecDrawer_totalText_posXpath).get_attribute("innerHTML") == "Total:0" # 正确校验 - self.driver.find_element(By.XPATH, groupObjectDetailPage_addSubObjecDrawer_searchInput_posXpath).clear() + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Delete_X text-[16px] mt-[-1px] cursor-pointer"]').click() self.driver.find_element(By.XPATH, groupObjectDetailPage_addSubObjecDrawer_searchInput_posXpath).send_keys(search_value + Keys.ENTER) # resulte_text = self.driver.find_element(By.XPATH,"//div[@class='IpItems list-box']//ul[@class='row-container tableList']/li[1]/div").text # 等待查询结果加载 @@ -3295,7 +3378,7 @@ class Accounts: self.wait.until(EC.visibility_of_element_located((By.XPATH, item_result_pos))) total_text = self.driver.find_element(By.XPATH,groupObjectDetailPage_addSubObjecDrawer_totalText_posXpath).get_attribute("innerHTML") assert total_text == "Total:1", "搜索结果错误,此时获取到的文本为{}".format(total_text) - self.driver.find_element(By.XPATH,acc_ObjectDetailPage_cancel_posXpath).click() + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() except Exception as e: raise e finally: @@ -3303,7 +3386,63 @@ class Accounts: self._del(data, search_value=self.my_item_name, del_flag=1) def _different_vsys_check(self, data): - self.objects_po.different_vsys_check("accounts", data) + self._create(data) + self.query(data) + # 获取UIAutoTestVsys的Object信息 + self.uiAutoTestVsys_object = dict(self.objects_po.table_dict) + print(self.uiAutoTestVsys_object) + # 切换Vsys至Vsys0 + self.profile_pub.change_vsys(vsys_name="vsys0") + self._create(data) + self.query(data) + self.vsys0_object = dict(self.objects_po.table_dict) + self._query(data) + time.sleep(2) + self.view_check("vsys0") + self.profile_pub.change_vsys(vsys_name="PerformanceTestVsys") + self._query(data) + time.sleep(2) + self.view_check("PerformanceTestVsys") + self.profile_pub.change_vsys(vsys_name="UIAutoTestVsys") + self._query(data) + time.sleep(2) + self.view_check("UIAutoTestVsys") + self.profile_pub.change_vsys(vsys_name="vsys0") + self._del(data) + + def view_check(self, vsys_name): + time.sleep(1) + total = self.driver.find_element(By.XPATH, "//span[contains(text(),'Total')]").text + count = total.split("Total:") + if vsys_name == "PerformanceTestVsys": + assert int(count[1]) == 1 + assert self.driver.find_element(By.XPATH, listPage_First_object_ID_posXpath).text == self.vsys0_object["UUID"] + elif vsys_name == "vsys0": + assert int(count[1]) == 1 + assert self.driver.find_element(By.XPATH, listPage_First_object_ID_posXpath).text == self.vsys0_object["UUID"] + # assert self.driver.find_element(By.XPATH, listPage_Second_object_ID_posXpath).text == self.uiAutoTestVsys_object["ID"] + # self.driver.find_element(By.XPATH,"//*[@id='ly-table1-listcontent']//tbody/tr[2]//span[@class='el-checkbox__inner']").click() + # self.driver.find_element(By.XPATH,"//button[@id='appEdit-_OperateBtns_ElRow_Objects_port_Home_App_anonymousComponent']//p[normalize-space(text()) = 'View']").click() + # assert len(self.driver.find_elements(By.XPATH, '//div[@class="IconBtn disabled-btn"]')) == 3 + # self.driver.isElementExist(port_ObjectDetailPage_mainOkButton_posXpath) + # assert self.driver.Exist == False + # self.driver.find_element(By.XPATH,port_ObjectPage_button_cancel_posXpath).click() + elif vsys_name == "UIAutoTestVsys": + assert int(count[1]) == 2 + assert self.driver.find_element(By.XPATH, listPage_First_object_ID_posXpath).text == self.vsys0_object["UUID"] + assert self.driver.find_element(By.XPATH, listPage_Second_object_ID_posXpath).text == self.uiAutoTestVsys_object["UUID"] + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_view_button_posXpath).click() + # add_item_disable = self.driver.element_isExist(by=By.XPATH,value="//div[@class='object-item-add']/div[@class='IconBtn disabled-btn']") + # edit_item_disable = self.driver.element_isExist(by=By.XPATH,value="//div[@class='list-container']//div[@class='IconBtn disabled-btn'][1]") + # del_item_disable = self.driver.element_isExist(by=By.XPATH,value="//div[@class='list-container']//div[@class='IconBtn disabled-btn'][2]") + # assert add_item_disable == edit_item_disable == del_item_disable == True + self.driver.isElementExist(port_ObjectDetailPage_mainOkButton_posXpath) + assert self.driver.Exist == False + self.driver.find_element(By.XPATH, port_ObjectPage_button_cancel_posXpath).click() + self.driver.find_element(By.XPATH, listpage_select_second_object_posXpath).click() + self.driver.find_element(By.XPATH, listpage_delete_button_posXpath).click() + self.driver.find_element(By.XPATH, port_listPage_deleteYes_posXpath).click() def _audit_log_all_operation(self, data): self._create(data) @@ -3328,14 +3467,12 @@ class Accounts: # 获取页面元素 self._just_goto_accountsPage() my_table_dict = self.objects_po.extract_ele() - details_first_value = self.driver.find_element(By.XPATH, - '(//div[@class="itemDetails cursor"][1]/span)[1]').text for search_type in search_type_list: - if search_type == "ID": + if search_type == "UUID": self.driver.find_element(By.XPATH,listpage_search_box_posXpath).click() self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys( - my_table_dict['ID']) - self.driver.find_element(By.ID, acc_listPage_object_searchId_posId).click() + my_table_dict['UUID']) + self.driver.find_element(By.XPATH, listPage_objectSearch_select_UUID_posXpath).click() elif search_type == "Name": self.driver.find_element(By.XPATH,listpage_search_box_posXpath).click() input_value = self.operate_input_value_4_multiple_search(my_table_dict['Name']) @@ -3346,16 +3483,14 @@ class Accounts: input_value = self.operate_input_value_4_multiple_search(my_table_dict['Description']) self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(input_value) self.driver.find_element(By.ID, acc_listPage_object_searchDescription_posId).click() - elif search_type == "Details": - self.driver.find_element(By.XPATH,listpage_search_box_posXpath).click() - input_value = self.operate_input_value_4_multiple_search(details_first_value) - self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(input_value) - self.driver.find_element(By.ID, acc_listPage_object_searchDetails_posId).click() + # elif search_type == "Details": + # self.driver.find_element(By.XPATH,listpage_search_box_posXpath).click() + # input_value = self.operate_input_value_4_multiple_search(details_first_value) + # self.driver.find_element(By.XPATH,listpage_search_box_posXpath).send_keys(input_value) + # self.driver.find_element(By.ID, acc_listPage_object_searchDetails_posId).click() search_button = self.driver.find_element(By.XPATH,listpage_search_button_posXpath) self.driver.execute_script("arguments[0].scrollIntoView();", search_button) search_button.click() - - self._query_verify(search_type="Details", search_value=details_first_value, need_verify_vsysID=0) except Exception as e: raise e finally: @@ -3392,28 +3527,27 @@ if __name__ == '__main__': acc = Accounts(demo_fixture=driver) driver.implicitly_wait(5) - driver.get("http://192.168.45.158") + driver.get("http://192.168.44.72") # driver.get("http://192.168.42.49") driver.maximize_window() - driver.find_element(By.XPATH, '//*[@id="root"]/div/div[2]/div/div[1]/input').send_keys("admin") - driver.find_element(By.XPATH, '//*[@id="root"]/div/div[2]/div/div[2]/input').send_keys("admin") - driver.find_element(By.XPATH, '//*[@id=":r0:"]').click() + driver.find_element(By.XPATH, '//input[@placeholder="User name"]').send_keys("guouitest") + driver.find_element(By.XPATH, '//input[@placeholder="Password"]').send_keys("jMIfnvhc1U") + driver.find_element(By.XPATH, '//button[@class="MuiButtonBase-root MuiButton-root MuiLoadingButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeLarge MuiButton-containedSizeLarge MuiButton-colorPrimary MuiButton-root MuiLoadingButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeLarge MuiButton-containedSizeLarge MuiButton-colorPrimary !bg-[#4487d4] css-zeizzp"]').click() # 切换Vsys # profile_pub = ProfilesPublicOperations(driver) # profile_pub.change_vsys(vsys_name='UIAutoTestVsys') - acc.acc_case(data= + acc._different_vsys_check(data= { - "ids": "Created By作为搜索条件进行模糊查询-T074-4", + "ids": "test_different_vsys_check", "Model": "create", "Type": 0, - "Name": "test_ui_test_ui323", - "Search type": "Created By", + "Search type": "Name", + "Name": "", "Items": [ - "[random]->" + "^skkj$" ], - "Description": "", - "Subordinate Objects": "" - }, + "Description": "" + } ) time.sleep(3) driver.quit() diff --git a/common/ui_common/objects/intervals.py b/common/ui_common/objects/intervals.py index cb7f0838..3cd77751 100644 --- a/common/ui_common/objects/intervals.py +++ b/common/ui_common/objects/intervals.py @@ -113,7 +113,7 @@ class Intervals: # no_modify = False if self.object_type == 0: # single Object self._operate_name(data, no_modify=no_modify) - # self._operate_object_statistics(data, no_modify=no_modify) + self._operate_object_statistics(data, no_modify=no_modify) self._operate_items(data, data_index=data_index, no_modify=no_modify) self._operate_description(data, no_modify=no_modify) else: # Object group @@ -139,9 +139,9 @@ class Intervals: def _select_object_statistics(self, my_object_statistics): # 展开下拉框 self.driver.find_element(By.XPATH, acc_ObjectDetailPage_objectStatistics_dropDown_posXpath).click() - if my_object_statistics == "Elaborate": + if my_object_statistics == "Brief": self.driver.find_element(By.XPATH, object_page_ln_select_statistics_elaborate_posXpath).click() - elif my_object_statistics == "Brief": + elif my_object_statistics == "Elaborate": self.driver.find_element(By.XPATH, object_page_ln_select_statistics_brief_posXpath).click() else: pass # 默认为None diff --git a/common/ui_common/objects/objects_public_operations.py b/common/ui_common/objects/objects_public_operations.py index 1875f4f3..b3348034 100644 --- a/common/ui_common/objects/objects_public_operations.py +++ b/common/ui_common/objects/objects_public_operations.py @@ -289,9 +289,9 @@ class ObjectsPublicOperations: # self.key_id = self.driver.find_element(By.XPATH, list_headers_id_posXpath).text # self.value_id = self.driver.find_element(By.XPATH, list_firstRow_values_id_posXpath).text - if need_exclude == 1: - self.uuid_name = self.driver.find_element(By.XPATH, '//div[text()="UUID"]').text - self.uuid_value = self.driver.find_element(By.XPATH,'//div[@aria-rowindex="2"]//div[@data-field="uuid"]').text + + self.uuid_name = self.driver.find_element(By.XPATH, '//div[text()="UUID"]').text + self.uuid_value = self.driver.find_element(By.XPATH,'//div[@aria-rowindex="2"]//div[@data-field="uuid"]').text self.key_vsys_id = self.driver.find_element(By.XPATH, '//div[text()="Vsys ID"]').text self.value_vsys_id = self.driver.find_element(By.XPATH, '//div[@aria-rowindex="2"]//div[@data-field="vsys"]').text @@ -315,7 +315,7 @@ class ObjectsPublicOperations: self.key_des: self.value_des,"Details": "null"} else: - self.table_dict = {self.key_vsys_id: self.value_vsys_id,self.key_name: self.value_name, self.key_des: self.value_des, + self.table_dict = {self.uuid_name:self.uuid_value,self.key_vsys_id: self.value_vsys_id,self.key_name: self.value_name, self.key_des: self.value_des, "Details": "null"} # print("extract_ele TEST:{}".format(self.table_dict)) return self.table_dict @@ -572,15 +572,19 @@ class ObjectsPublicOperations: def View_statistics(self, edit_element): # 主界面View验证 self.driver.find_element(By.XPATH, main_listPage_object_statistics_view_postXpath).click() - self.driver.isElementExist(Element="(//div[@class='ObjectStatisticSlider'])[1]") + self.driver.isElementExist(Element='//i[@class="iconfont icon-Clear_aNormal close-icon"]') assert self.driver.Exist, "Statistics界面打开" - self.driver.find_element(By.XPATH, "(//div[@class='ObjectStatisticSlider']//span[text()='Cancel'])[2]").click() + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() + time.sleep(2) # 详情界面Statistics验证 - self.driver.find_element(By.XPATH, listPage_object_ip_address_select_First_object_posXpath).click() - self.driver.find_element(By.ID, edit_element).click() - self.driver.find_element(By.XPATH, "//div[@class='paper-grid-right']//span[text()='Statistics']").click() - self.driver.isElementExist(Element="(//div[@class='ObjectStatisticSlider'])[1]") + # self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH, edit_element).click() + self.driver.find_element(By.XPATH, '(//button[text()="Statistics"])[1]').click() + self.driver.isElementExist(Element='(//i[@class="iconfont icon-Clear_aNormal close-icon"])[2]') assert self.driver.Exist, "Statistics界面打开" + time.sleep(2) + self.driver.find_element(By.XPATH, '(//i[@class="iconfont icon-Clear_aNormal close-icon"])[2]').click() + time.sleep(2) def Duplicate_check(self, data): self.driver.isElementExist(Element=listPage_object_reprtition_check_postXpath) @@ -2236,7 +2240,7 @@ class ObjectsPublicOperations: self.driver.find_element(By.XPATH, listPage_auditlogSearch_buttonSearch_posXpath).click() # 搜索 assert len(self.driver.find_elements(By.XPATH,"//div[@data-field='op_type']//span[text()='Create']")) == 1,"Create日记大于1" - assert len(self.driver.find_elements(By.XPATH,"//div[@data-field='op_type']//span[text()='Edit']")) > 2,"Edit日志大于1" + assert len(self.driver.find_elements(By.XPATH,"//div[@data-field='op_type']//span[text()='Edit']")) >= 1,"Edit日志大于1" assert len(self.driver.find_elements(By.XPATH,"//div[@data-field='op_type']//span[text()='Delete']")) == 1,"Delete日志大于1" time.sleep(1) operation_text_elements = self.driver.find_elements(By.XPATH,"//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='op_type']") @@ -2245,8 +2249,8 @@ class ObjectsPublicOperations: else: operation = ["Create", "Edit", "Delete", "Query Verbose"] operation_text = [] - for i in range(1,len(operation_text_elements)): - text = self.driver.find_element(By.XPATH,f"(//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='op_type']/span)[{i + 1}]").text + for i in range(1,len(operation_text_elements)+1): + text = self.driver.find_element(By.XPATH,f"(//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='op_type']/span)[{i}]").text operation_text.append(text) self.check_audit_log_detail("0") if set(operation_text) != set(operation): @@ -2254,21 +2258,21 @@ class ObjectsPublicOperations: ###校验["Export","Query List"] # 清除筛选框 - search_clear_btn = self.driver.find_element(By.XPATH,listPage_auditlogSearch_input_posXpath) - self.driver.execute_script("arguments[0].scrollIntoView();", search_clear_btn) - search_clear_btn.click() - object_type = "Object" + # search_clear_btn = self.driver.find_element(By.XPATH,listPage_auditlogSearch_input_posXpath) + # self.driver.execute_script("arguments[0].scrollIntoView();", search_clear_btn) + # search_clear_btn.click() + self.driver.find_element(By.XPATH, '//span[text()="Audit Logs"]').click() self.driver.find_element(By.XPATH, listPage_auditlogSearch_input_posXpath).click() self.driver.find_element(By.XPATH, listPage_auditlogSearch_select_TargetType_posXpath).click() scrollable_div = self.driver.find_element(By.XPATH,f"//ul[@class='base-Popper-root MuiSelect-listbox Mui-expanded css-1wd16dk']//li[text()='{object_type}']") self.driver.execute_script("arguments[0].scrollIntoView();", scrollable_div) scrollable_div.click() # 选择当前用户 - self.driver.find_element(By.XPATH, listPage_auditlogSearch_input_posXpath).click() - self.driver.find_element(By.XPATH, listPage_auditlogSearch_select_UserName_posXpath).click() - self.driver.find_element(By.XPATH, listPage_auditlogSearch_username_text_posXpath).send_keys(user_name) - time.sleep(2) - self.driver.find_element(By.XPATH, f"//div[@x-placement='bottom-start']//span[text()='{user_name}']").click() + # self.driver.find_element(By.XPATH, listPage_auditlogSearch_input_posXpath).click() + # self.driver.find_element(By.XPATH, listPage_auditlogSearch_select_UserName_posXpath).click() + # self.driver.find_element(By.XPATH, listPage_auditlogSearch_username_text_posXpath).send_keys(user_name) + # time.sleep(2) + # self.driver.find_element(By.XPATH, f"//div[@x-placement='bottom-start']//span[text()='{user_name}']").click() # 搜索 self.driver.find_element(By.XPATH, listPage_auditlogSearch_buttonSearch_posXpath).click() @@ -2276,16 +2280,15 @@ class ObjectsPublicOperations: operation_text_elements = self.driver.find_elements(By.XPATH,"//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='op_type']") other_operation_text = [] if export_verify == 1: - other_operation = ["Export", "Query List","Create", "Edit", "Delete", "Import", "Query Verbose"] + other_operation = ["Export", "Query List"] else: - other_operation = ["Query List","Create", "Edit", "Delete", "Query Verbose"] + other_operation = ["Query List"] for i in range(len(operation_text_elements)): text = self.driver.find_element(By.XPATH,f"(//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='op_type'])[{i + 1}]").text other_operation_text.append(text) self.check_audit_log_detail("1") print(other_operation_text, set(other_operation_text), len(operation_text_elements)) - if set(other_operation_text) != set(other_operation): - raise Exception("存在未记录日志") + assert other_operation in set(other_operation_text) def check_audit_log_detail(self, type): if type == "0": # 首次对operation = ["Create", "Edit", "Delete", "Import", "Query Verbose"]的校验 @@ -2297,21 +2300,21 @@ class ObjectsPublicOperations: compare_verision = self.driver.find_elements(By.XPATH, "//div[@class='overflow-hidden']//tbody//tr") assert len(compare_verision) != 0, "Compare存在修改信息" elif detaile_text == "View": - assert self.driver.find_element(By.XPATH, url_ObjectDetailPage_auditLogsDrawer_compareDrawer_operationText_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_type_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_ip_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_time_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_user_posXpath).text != "" - self.driver.find_element(By.ID,"interceptionadd_allcancelobject10-_AuditLogs_system_PolicyConfigurationLog_Home_App_anonymousComponent").click() + assert self.driver.find_element(By.XPATH, url_ObjectDetailPage_auditLogsDrawer_compareDrawer_operationText_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_type_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_ip_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_time_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_user_posXpath1).text != "" + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() elif type == "1": # 对 other_operation = ["Export", "Query List"]的校验 detaile_elements = self.driver.find_elements(By.XPATH,"//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='details']") detaile_index = random.randint(1, len(detaile_elements)) self.driver.find_element(By.XPATH,f"(//div[@class='MuiDataGrid-virtualScrollerContent css-0']//div[@data-field='details'])[{detaile_index + 1}]").click() - assert self.driver.find_element(By.XPATH,url_ObjectDetailPage_auditLogsDrawer_compareDrawer_operationText_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_type_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_ip_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_time_posXpath).text != "" - assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_user_posXpath).text != "" + assert self.driver.find_element(By.XPATH,url_ObjectDetailPage_auditLogsDrawer_compareDrawer_operationText_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_type_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_ip_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_time_posXpath1).text != "" + assert self.driver.find_element(By.XPATH, ObjectDetailPage_audit_log_compare_user_posXpath1).text != "" # self.driver.find_element(By.XPATH,"(//button[@id='test-compareHistorical-_system_PolicyConfigurationLog_Home_App_anonymousComponent']//span[normalize-space(text())='Compare'])[1]").click() # compare_verision = self.driver.find_elements(By.XPATH,"//div[@class='rm-content']//div[@class='el-table__body-wrapper is-scrolling-none']//tr[@class='el-table__row']") # assert len(compare_verision) != 0,"Compare存在修改信息" diff --git a/common/ui_common/objects/tunnels.py b/common/ui_common/objects/tunnels.py index 05ac03d5..519d9d0d 100644 --- a/common/ui_common/objects/tunnels.py +++ b/common/ui_common/objects/tunnels.py @@ -102,12 +102,12 @@ class Tunnels: self.driver.find_element(By.XPATH,mainPage_firstLevelMenu_Objects_posXpath).click() self.driver.find_element(By.XPATH,mainPage_secondLevelMenu_Tunnel_posXpath).click() # 增加首次进入时验证Total和首行是否存在 - if self.my_count == 0: - total_text = self.driver.find_element(By.XPATH, main_listPage_object_bottomTotal_postXpath).text - total_value = int(total_text.split(":")[-1].strip()) - is_first_exist = self.driver.element_isExist(By.XPATH, list_first_row_first_column_posXpath) - assert is_first_exist or total_value == 0, "校验失败!!列表页为空!!" - self.my_count += 1 + # if self.my_count == 0: + # total_text = self.driver.find_element(By.XPATH, main_listPage_object_bottomTotal_postXpath).text + # total_value = int(total_text.split(":")[-1].strip()) + # is_first_exist = self.driver.element_isExist(By.XPATH, list_first_row_first_column_posXpath) + # assert is_first_exist or total_value == 0, "校验失败!!列表页为空!!" + # self.my_count += 1 def pop_export_part(self): self.driver.find_element(By.XPATH, listPage_object_Tunnels_exportButton_posXPATH).click() @@ -147,7 +147,7 @@ class Tunnels: def _export_objects_and_verify(self, data): self._create(data) # 新建,新建后就是查询到该条数据的状态 - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() # 选中第一行 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 选中第一行 self._export_objects() # 选中并导出文件 time.sleep(3) self.file_name = get_txt_filenames(path=self.my_files._obj_files_dowload_path()) @@ -169,17 +169,17 @@ class Tunnels: self.create_tunnel(data) # 新建,新建后就是查询到该条数据的状态 if data["SubType"] == "cancel_export": # 1、单个Object导出取消选中目标数据 - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() self.pop_cancel_export_num() self.create_tunnel(data) # 2、多个Object导出取消选中目标数据(2个) - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_second_object_posXpath).click() self.pop_cancel_export_num() self._delete(data) elif data["SubType"] == "multi_export": self.create_tunnel(data) - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_second_object_posXpath).click() if data["multi_type"] == "all": # 4、多选导出所有数据,校验行数 self._export_objects() @@ -262,7 +262,7 @@ class Tunnels: # self._goto_subObjectPage() # self._search(data) # 查询后编辑 - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() self.driver.find_element(By.XPATH, listPage_object_Tunnels_editButton_posXPATH).click() # edit按钮 def _verify_not_checkbox_export(self, data: {}): @@ -315,7 +315,7 @@ class Tunnels: # 调用消除右上提示弹窗 self._goto_subObjectPage() # first_quoted_tunnel_elem_posXpath = '(//*[@class="obj-charts-btn pro-port cursorPointer textCenter" and text() != 0])[1]/parent::div/parent::div/parent::td' - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() del_button_elem = listPage_object_Tunnels_delButton_posXpath del_button_elem_clickable = self.objects_po.is_element_clickable(del_button_elem, "XPATH") print("当前元素是否可点击:{}".format(del_button_elem_clickable)) @@ -393,10 +393,10 @@ class Tunnels: search_types = data["Search_type"].split('&') for search_type in search_types: if not fuzzy_search: - if search_type == "ID": + if search_type == "UUID": self.driver.find_element(By.XPATH, listpage_search_box_posXpath).click() - self.driver.find_element(By.XPATH, listpage_search_box_posXpath).send_keys(self.table_dict['ID']) - self.driver.find_element(By.XPATH, listPage_objectSearch_Tunnels_select_Id_posId).click() + self.driver.find_element(By.XPATH, listpage_search_box_posXpath).send_keys(self.table_dict['UUID']) + self.driver.find_element(By.XPATH, listPage_objectSearch_select_UUID_posXpath).click() elif search_type == "Name": self.driver.find_element(By.XPATH, listpage_search_box_posXpath).click() input_value = self.operate_input_value_4_multiple_search(self.table_dict['Name']) @@ -405,7 +405,7 @@ class Tunnels: self.driver.find_element(By.XPATH, listPage_objectSearch_Tunnels_select_Name_posId).click() elif search_type == "IP": self.driver.find_element(By.XPATH, listpage_search_box_posXpath).click() - input_value = self.operate_input_value_4_multiple_search(self.table_dict['Details']) + input_value = self.operate_input_value_4_multiple_search("2.2.2.3") self.driver.find_element(By.XPATH, listpage_search_box_posXpath).send_keys( input_value) self.driver.find_element(By.XPATH, listPage_objectSearch_Tunnels_select_IP_posId).click() @@ -416,7 +416,7 @@ class Tunnels: input_value) self.driver.find_element(By.XPATH, listPage_objectSearch_Tunnels_select_Name_posId).click() else: # 全局查询 - if search_type == "ID": + if search_type == "UUID": self.driver.find_element(By.XPATH, listpage_search_box_posXpath).click() self.driver.find_element(By.XPATH, listpage_search_box_posXpath).send_keys(self.table_dict['ID']) elif search_type == "Name": @@ -505,6 +505,7 @@ class Tunnels: # 通过Name查询,查看内容是否和新建时一致 # self.extract_ele_tunnel() ## 提取ID、Name、Description、Detail self.table_dict = self.objects_po.extract_ele(need_exclude=2) + print(self.table_dict) # first_detail_elem = self.driver.find_element(By.XPATH,'(//div[@class="itemDetails cursor"]//div[@class="three-row list-popover-click"])[1]') # ActionChains(self.driver).move_to_element(first_detail_elem).perform() # first_detail_ip_elem = self.driver.find_element(By.XPATH,'((//div[contains(@x-placement,"right-start")]//td)[last()]//div)[last()]') @@ -558,17 +559,17 @@ class Tunnels: self.driver.find_element(By.XPATH, tunnel_ip_list_close).click() ##endpoint B中新建ip object group - self.driver.find_element(By.XPATH, tunnel_add_endpoint_b).click() - self.driver.find_element(By.XPATH, tunnel_add_item_2).click() - self.driver.find_element(By.XPATH, tunnel_ip_list_add_button).click() - self.driver.find_element(By.XPATH, tunnel_ip_list_select_ip_group).click() - self.driver.find_element(By.XPATH, tunnel_slide_ip_name).send_keys("test_ui_4_tunnle") - self.driver.find_element(By.XPATH, tunnel_ip_group_add_subobject).click() - self.driver.find_element(By.XPATH, tunnel_ip_group_first_row).click() - self.driver.find_element(By.XPATH, tunnel_ip_list_close2).click() - self.driver.find_element(By.XPATH, tunnel_slide_ip_ok).click() - # self.driver.find_element(By.XPATH, tunnel_slide_ip_confirm_ok).click() - self.driver.find_element(By.XPATH, tunnel_ip_list_close).click() + # self.driver.find_element(By.XPATH, tunnel_add_endpoint_b).click() + # self.driver.find_element(By.XPATH, tunnel_add_item_2).click() + # self.driver.find_element(By.XPATH, tunnel_ip_list_add_button).click() + # self.driver.find_element(By.XPATH, tunnel_ip_list_select_ip_group).click() + # self.driver.find_element(By.XPATH, tunnel_slide_ip_name).send_keys("test_ui_4_tunnle") + # self.driver.find_element(By.XPATH, tunnel_ip_group_add_subobject).click() + # self.driver.find_element(By.XPATH, tunnel_ip_group_first_row).click() + # self.driver.find_element(By.XPATH, tunnel_ip_list_close2).click() + # self.driver.find_element(By.XPATH, tunnel_slide_ip_ok).click() + # # self.driver.find_element(By.XPATH, tunnel_slide_ip_confirm_ok).click() + # self.driver.find_element(By.XPATH, tunnel_ip_list_close).click() # 确认保存 self.driver.find_element(By.XPATH,TunnelsObjectPage_button_SaveYes_posXpath).click() @@ -576,6 +577,7 @@ class Tunnels: # self.extract_ele_tunnel() ## 提取ID、Name、Description、Detail self.table_dict = self.objects_po.extract_ele(need_exclude=2) + print(self.table_dict) # first_detail_elem = self.driver.find_element(By.XPATH,'(//div[@class="itemDetails cursor"]//div[@class="three-row list-popover-click"])[1]') # time.sleep(1) # ActionChains(self.driver).move_to_element(first_detail_elem).perform() @@ -592,7 +594,7 @@ class Tunnels: if "isDeleteGroup" in data and data["isDeleteGroup"] == "True": # self.driver.find_element(By.XPATH, mainPage_secondLevelMenu_ipAddress_posXpath).send_keys( # "test_ui_4_tunnle") - # self.driver.find_element(By.XPATH, listPage_objectSearch_ip_address_select_Name_posXpath).click() + # self.driver.find_element(By.XPATH, listPage_objectSearch_select_Name_posXpath).click() # self.driver.find_element(By.XPATH, listpage_search_button_posXpath).click() # # 尝试定位第一个对象,如果找到则执行删除操作 # try: @@ -606,9 +608,9 @@ class Tunnels: # # 如果没有找到元素,打印消息并跳过删除操作 # print("未找到第一个对象,跳过删除操作") # 筛选目标数据 - self.driver.find_element(By.XPATH, mainPage_secondLevelMenu_ipAddress_posXpath).send_keys( + self.driver.find_element(By.XPATH, listpage_search_input_posXpath).send_keys( "test_ui_4_tunnle") - self.driver.find_element(By.XPATH, listPage_objectSearch_ip_address_select_Name_posXpath).click() + self.driver.find_element(By.XPATH, listPage_objectSearch_select_Name_posXpath).click() self.driver.find_element(By.XPATH, listpage_search_button_posXpath).click() is_target_exist = self.driver.element_isExist(By.XPATH, listPage_object_tableCheckbox_localVsysAndReferenceEqualO_objectOrGroup_posXpaths) @@ -625,13 +627,14 @@ class Tunnels: self.driver.find_element(By.XPATH,listPage_object_ip_address_delButton_posXpath).click() self.driver.find_element(By.XPATH, listPage_object_ip_address_del_yes_Button_posXpath).click() time.sleep(2) + self.driver.refresh() # 筛选目标数据 - self.driver.find_element(By.XPATH, mainPage_secondLevelMenu_ipAddress_posXpath).send_keys( + self.driver.find_element(By.XPATH, listpage_search_input_posXpath).send_keys( "test_ui_4_tunnle") - # element = self.driver.find_element(By.XPATH, listPage_objectSearch_ip_address_select_Name_posXpath) + # element = self.driver.find_element(By.XPATH, listPage_objectSearch_select_Name_posXpath) # self.driver.execute_script("arguments[0].scrollIntoView();", element) # element.click() - self.wait.until(EC.presence_of_element_located((By.XPATH,listPage_objectSearch_ip_address_select_Name_posXpath))).click() + self.wait.until(EC.presence_of_element_located((By.XPATH,listPage_objectSearch_select_Name_posXpath))).click() self.driver.find_element(By.XPATH, listpage_search_button_posXpath).click() time.sleep(2) is_target_exist = self.driver.element_isExist(By.XPATH, @@ -693,7 +696,7 @@ class Tunnels: self.random_name = self.my_random.random_name() # 重新生成一个random_name self.random_item = self.my_random.random_tunnel() # 重新生成的endpoint # 查询后EditName - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() # 第一行数据前的复选框 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 第一行数据前的复选框 self.driver.find_element(By.XPATH, listPage_object_Tunnels_editButton_posXPATH).click() # edit按钮 self.objects_po.clear_Name(path=Tunnel_ObjectPage_InputName_posXpath) # 清除name self.driver.find_element(By.XPATH, Tunnel_ObjectPage_InputName_posXpath).send_keys(self.random_name) # 重新输入name @@ -710,7 +713,7 @@ class Tunnels: def _delete(self, data): # self._goto_subObjectPage() self._search(data) - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() # 选择第一个对象 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 选择第一个对象 # 确认删除 self.driver.find_element(By.XPATH,listPage_object_Tunnels_delButton_posXpath).click() self.driver.find_element(By.XPATH, listPage_object_Tunnels_del_yes_Button_posXpath).click() @@ -761,8 +764,8 @@ class Tunnels: # self.key12 = self.driver.find_element(By.XPATH, list_first_row_second_column_posXpath).text # self.value22 = self.driver.find_element(By.XPATH, list_second_row_second_column_posXpath).text # Name - self.key13 = self.driver.find_element(By.XPATH, list_first_row_third_column_posXpath).text - self.value23 = self.driver.find_element(By.XPATH, "//div[@class='MuiDataGrid-virtualScrollerRenderZone css-1inm7gi']/div[1]//div[@data-field='name']//span[@class='truncate']").text + self.key13 = self.driver.find_element(By.XPATH, '//div[text()="Name"]').text + self.value23 = self.driver.find_element(By.XPATH, '//div[@aria-rowindex="2"]//span[@class="truncate"]').text # 字典 # self.edit_table_dict = {self.key11: self.value12, self.key12: self.value22, self.key13: self.value23} self.edit_table_dict = {self.key13: self.value23} @@ -770,14 +773,15 @@ class Tunnels: def new_security_policy_tunnel(self, data: {}): # 跳转到安全策略创建页面 - self.driver.find_element(By.ID, mainPage_firstLevelMenu_Policy_posId).click() - self.driver.find_element(By.ID, mainPage_secondLevelMenu_Security_posId).click() + self.driver.find_element(By.XPATH, mainPage_firstLevelMenu_Policy_posXpath).click() + self.driver.find_element(By.XPATH, mainPage_secondLevelMenu_Security_posXpath).click() # 添加tunnel self.driver.find_element(By.XPATH, listpage_create_button_posXpath).click() self.driver.find_element(By.XPATH, security_create_Name_input_frame_PosXpath).send_keys(data["Name"]) self.driver.find_element(By.XPATH, security_policy_add_condition_button_by_xpath).click() # 选择Condition按钮 self.driver.find_element(By.XPATH, security_create_add_tunnel_button_click_PosXpath).click() # 选择tunnel + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() time.sleep(2) self.driver.find_element(By.XPATH, security_add_tunnel_button).click() # 添加tunnel # self.driver.find_element(By.XPATH, security_search_tunnel_frame_click_PosXpath).send_keys( @@ -790,8 +794,9 @@ class Tunnels: print('正常找到Object,正常进行引用创建') self.driver.find_element(By.XPATH, security_first_tunnel_inlist_click_PosXpath).click() + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() self.driver.find_element(By.XPATH, security_create_ok_click_posXpath).click() - self.driver.find_element(By.XPATH, security_create_Warn_ok_click_posXpath).click() + # self.driver.find_element(By.XPATH, security_create_Warn_ok_click_posXpath).click() else: # 不存在就跳过 assert self.driver.Exist == False # 未找到元素 print('未找到Object,无法进行引用创建') @@ -1361,7 +1366,7 @@ class Tunnels: self._goto_subObjectPage() self._search(data) # 修改数据 - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() # 第一行数据前的复选框 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 第一行数据前的复选框 self.driver.find_element(By.XPATH, listPage_object_Tunnels_editButton_posXPATH).click() # edit按钮 self.objects_po.clear_Name(path=Tunnel_ObjectPage_InputName_posXpath) # 清除name self.driver.find_element(By.XPATH, Tunnel_ObjectPage_InputName_posXpath).send_keys( @@ -1435,7 +1440,7 @@ class Tunnels: compare_list_detail.append(des_value_detail) # 在目的vsys中修改 self.driver.find_element(By.XPATH, - listPage_object_Tunnels_select_First_object_posXpath).click() # 第一行数据前的复选框 + listPage_select_first_object_posXpath).click() # 第一行数据前的复选框 self.driver.find_element(By.XPATH, listPage_object_Tunnels_editButton_posXPATH).click() # edit按钮 self.objects_po.clear_Name(path=Tunnel_ObjectPage_InputName_posXpath) # 清除name self.driver.find_element(By.XPATH, Tunnel_ObjectPage_InputName_posXpath).send_keys( @@ -1483,7 +1488,7 @@ class Tunnels: self.driver.find_element(By.XPATH, listpage_search_box_posXpath).send_keys(Des_ID_list[0]) self.driver.find_element(By.ID, listPage_objectSearch_Tunnels_select_Id_posId).click() self.driver.find_element(By.XPATH,listpage_search_button_posXpath).click() - self.driver.find_element(By.XPATH, listPage_object_Tunnels_select_First_object_posXpath).click() # 选择第一个对象 + self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() # 选择第一个对象 # 确认删除 self.driver.find_element(By.XPATH,listPage_object_Tunnels_delButton_posXpath).click() self.driver.find_element(By.XPATH, listPage_object_Tunnels_del_yes_Button_posXpath).click() @@ -1500,21 +1505,23 @@ class Tunnels: def View_statistics(self, edit_element): # 主界面View验证 - self.driver.find_element(By.XPATH, - - '(//span[@id="tunnelStatistics-_Objects_tunnel_Home_App_anonymousComponent" and text()="View"])[1]').click() - self.driver.isElementExist(Element="(//div[@class='ObjectStatisticSlider'])[1]") + self.driver.find_element(By.XPATH, main_listPage_object_statistics_view_postXpath).click() + self.driver.isElementExist(Element='//i[@class="iconfont icon-Clear_aNormal close-icon"]') assert self.driver.Exist, "Statistics界面打开" - self.driver.find_element(By.XPATH, "(//div[@class='ObjectStatisticSlider']//span[text()='Cancel'])[2]").click() + self.driver.find_element(By.XPATH, '//i[@class="iconfont icon-Clear_aNormal close-icon"]').click() + time.sleep(2) # 详情界面Statistics验证 - self.driver.find_element(By.XPATH, listPage_object_ip_address_select_First_object_posXpath).click() + # self.driver.find_element(By.XPATH, listPage_select_first_object_posXpath).click() self.driver.find_element(By.XPATH, edit_element).click() - self.driver.find_element(By.XPATH, "//div[@class='paper-grid-right']//span[text()='Statistics']").click() - self.driver.isElementExist(Element="(//div[@class='ObjectStatisticSlider'])[1]") + self.driver.find_element(By.XPATH, '(//button[text()="Statistics"])[1]').click() + self.driver.isElementExist(Element='//div[text()="Object Statistics"]') assert self.driver.Exist, "Statistics界面打开" + time.sleep(2) + self.driver.find_element(By.XPATH, '(//i[@class="iconfont icon-Clear_aNormal close-icon"])').click() + time.sleep(2) def modify_tunnel(self, data): - self.create_tunnel(data) + self._create(data) self._modify2(data) self._delete(data) # self.delete_created_ip_bymself(data) @@ -1525,9 +1532,8 @@ class Tunnels: self.select_first_row_data_and_edit(data) # 选择该按钮删除endpoint B self.driver.find_element(By.XPATH, - '//*[@id="endpointDelItem-_EndpointBList_ElFormItem_ElForm_VPanel_VEditPanel_tunnelAdd_Home_App_anonymousComponent"]/i') - self.driver.find_element(By.XPATH, - '//*[@id="endpointDelItem-_EndpointBList_ElFormItem_ElForm_VPanel_VEditPanel_tunnelAdd_Home_App_anonymousComponent"]/i').click() + '//div[@class="tunnel-object-endpointB"]//i[contains(@class,"icon-Delete")]').click() + self.driver.find_element(By.XPATH, '//div[@class="tunnel-object-endpointB"]//I[@class="iconfont icon-retract cursor block text-[22px]"]').click() self.driver.find_element(By.XPATH,TunnelsObjectPage_button_SaveYes_posXpath).click() # self.driver.find_element(By.CSS_SELECTOR, TunnelsObjectPage_button_warningSaveYes_posSelector).click() # 断言修改name是否生效 @@ -1535,7 +1541,7 @@ class Tunnels: time.sleep(3) self._search(data) self.select_first_row_data_and_edit(data) - self.driver.isElementExist(Element=tunnel_add_item_2) + self.driver.isElementExist(Element=tunnel_end_point_b_frame) assert not self.driver.Exist, "endpoint已关闭" @screenshot_on_failure @@ -1629,7 +1635,74 @@ class Tunnels: self.driver.find_element(By.XPATH, listPage_object_Keywords_del_yes_Button_posXpath).click() def _different_vsys_check(self, data): - self.objects_po.different_vsys_check("tunnels", data) + self.create_tunnel(data) + # 获取UIAutoTestVsys的Object信息 + self.uiAutoTestVsys_object = dict(self.objects_po.table_dict) + # 切换Vsys至Vsys0 + self.profile_pub.change_vsys(vsys_name="vsys0") + self.create_tunnel(data) + self.vsys0_object = dict(self.objects_po.table_dict) + self._search(data) + column_setting_btn = self.driver.find_element(By.XPATH, + mainPage_ObjectSearch_Column_settings_posXpath) # 列设置按钮 + self.driver.execute_script("arguments[0].scrollIntoView();", column_setting_btn) + column_setting_btn.click() # 点击列设置 + self.driver.find_element(By.XPATH, '//span[text()="Vsys ID"]').click() + self.driver.find_element(By.XPATH, '//span[text()="UUID" and contains(@class,"MuiTypography-body1")]').click() + # self.driver.find_element(By.XPATH, "//input[@name='Show/Hide All']").click() + # self.driver.find_element(By.XPATH, "//input[@name='Show/Hide All']").click() + self.driver.find_element(By.XPATH, '//div[text()="Name"]').click() + self.view_check("vsys0") + self.profile_pub.change_vsys(vsys_name="PerformanceTestVsys") + self._search(data) + self.view_check("PerformanceTestVsys") + self.profile_pub.change_vsys(vsys_name="UIAutoTestVsys") + self._search(data) + column_setting_btn = self.driver.find_element(By.XPATH, + mainPage_ObjectSearch_Column_settings_posXpath) # 列设置按钮 + self.driver.execute_script("arguments[0].scrollIntoView();", column_setting_btn) + column_setting_btn.click() # 点击列设置 + self.driver.find_element(By.XPATH, '//span[text()="Vsys ID"]').click() + self.driver.find_element(By.XPATH, '//span[text()="UUID" and contains(@class,"MuiTypography-body1")]').click() + # self.driver.find_element(By.XPATH, "//input[@name='Show/Hide All']").click() + # self.driver.find_element(By.XPATH, "//input[@name='Show/Hide All']").click() + self.driver.find_element(By.XPATH, '//div[text()="Name"]').click() + self.view_check("UIAutoTestVsys") + self.profile_pub.change_vsys(vsys_name="vsys0") + self._delete(data) + + def view_check(self,vsys_name): + time.sleep(1) + total = self.driver.find_element(By.XPATH,"//span[contains(text(),'Total')]").text + count = total.split("Total:") + if vsys_name == "PerformanceTestVsys": + assert int(count[1]) == 1 + elif vsys_name =="vsys0": + assert int(count[1]) == 1 + assert self.driver.find_element(By.XPATH, listPage_First_object_ID_posXpath).text == self.vsys0_object["UUID"] + # assert self.driver.find_element(By.XPATH, listPage_Second_object_ID_posXpath).text == self.uiAutoTestVsys_object["ID"] + # self.driver.find_element(By.XPATH,"//*[@id='ly-table1-listcontent']//tbody/tr[2]//span[@class='el-checkbox__inner']").click() + # self.driver.find_element(By.XPATH,"//button[@id='appEdit-_OperateBtns_ElRow_Objects_apn_Home_App_anonymousComponent']//p[normalize-space(text()) = 'View']").click() + # assert len(self.driver.find_elements(By.XPATH, '//div[@class="IconBtn disabled-btn"]')) == 3 + # self.driver.isElementExist(APNsObjectPage_button_SaveYes_posXpath) + # assert self.driver.Exist == False + # self.driver.find_element(By.XPATH,apn_ObjectPage_button_cancel_posXpath).click() + elif vsys_name == "UIAutoTestVsys": + assert int(count[1]) == 2 + assert self.driver.find_element(By.XPATH, listPage_First_object_ID_posXpath).text == self.vsys0_object["UUID"] + assert self.driver.find_element(By.XPATH, listPage_Second_object_ID_posXpath).text == self.uiAutoTestVsys_object["UUID"] + self.driver.find_element(By.XPATH,listPage_select_first_object_posXpath).click() + self.driver.find_element(By.XPATH,'//span[text()="View"]').click() + # add_item_disable = self.driver.element_isExist(by=By.XPATH,value="//div[@class='object-item-add']/div[@class='IconBtn disabled-btn']") + # edit_item_disable = self.driver.element_isExist(by=By.XPATH,value="//div[@class='list-container']//div[@class='IconBtn disabled-btn'][1]") + # del_item_disable = self.driver.element_isExist(by=By.XPATH,value="//div[@class='list-container']//div[@class='IconBtn disabled-btn'][2]") + # assert add_item_disable == edit_item_disable == del_item_disable == True + self.driver.isElementExist(APNsObjectPage_button_SaveYes_posXpath) + assert self.driver.Exist == False + self.driver.find_element(By.XPATH, port_ObjectPage_button_cancel_posXpath).click() + self.driver.find_element(By.XPATH, listpage_select_second_object_posXpath).click() + self.driver.find_element(By.XPATH, listPage_object_apns_delButton_posXpath).click() + self.driver.find_element(By.XPATH, listPage_object_apns_deleteYes_posXpath).click() def _audit_log_all_operation(self, data): try: @@ -1664,27 +1737,33 @@ if __name__ == '__main__': tun = Tunnels(demo_fixture=driver) driver.implicitly_wait(5) - driver.get("http://192.168.45.158") + driver.get("http://192.168.44.72") # driver.get("http://192.168.42.49") driver.maximize_window() # driver.find_element(By.NAME, 'username').send_keys("Gary") # driver.find_element(By.NAME, 'password').send_keys("4garyautoui") - driver.find_element(By.XPATH, '//input[@placeholder="User name"]').send_keys("admin") - driver.find_element(By.XPATH, '//input[@placeholder="Password"]').send_keys("admin") + driver.find_element(By.XPATH, '//input[@placeholder="User name"]').send_keys("guouitest") + driver.find_element(By.XPATH, '//input[@placeholder="Password"]').send_keys("jMIfnvhc1U") # driver.find_element(By.NAME, 'username').send_keys("User4Link") # driver.find_element(By.NAME, 'password').send_keys("User4Link") driver.find_element(By.XPATH, '//button[@class="MuiButtonBase-root MuiButton-root MuiLoadingButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeLarge MuiButton-containedSizeLarge MuiButton-colorPrimary MuiButton-root MuiLoadingButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeLarge MuiButton-containedSizeLarge MuiButton-colorPrimary !bg-[#4487d4] css-zeizzp"]').click() # 切换Vsys # profile_pub = ProfilesPublicOperations(driver) # profile_pub.change_vsys(vsys_name='UIAutoTestVsys') - tun.tunnels_case(data= + tun.create_tunnel(data= { - "ids": "Tunnel的增删改查:IP", - "CreatType": "Tunnel", - "SubType": "", - "Search_type": "Name", - "type": "IP" - } + "ids": "Tunnel中根据IP查询", + "Search_type": "IP", + "type": "IP", + "isDeleteGroup": "True" + }, ) + tun._delete(data= + { + "ids": "Tunnel中根据IP查询", + "Search_type": "IP", + "type": "IP", + "isDeleteGroup": "True" + },) time.sleep(3) driver.quit() |
