summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguowenzheng <[email protected]>2024-10-29 09:53:33 +0800
committerguowenzheng <[email protected]>2024-10-29 09:53:33 +0800
commite6106ab24f8042fedb66186e14cd270f83a035b7 (patch)
treee9dd9e968b1c03a1f65dcc5971125c652c2b8c7a
parented6b0d532476e0e1c3ae8e69a19f8d4d52e8a3e9 (diff)
元素定位逻辑修改
-rw-r--r--common/ui_common/objects/apns.py26
-rw-r--r--common/ui_common/objects/objects_public_operations.py4
-rw-r--r--common/ui_common/objects/ports.py64
-rw-r--r--page_element/objects_element_position.py4
-rw-r--r--testdata/ui_data/objects_data/Ports/base_ports.json2
-rw-r--r--testdata/ui_data/objects_data/apns.json1
6 files changed, 68 insertions, 33 deletions
diff --git a/common/ui_common/objects/apns.py b/common/ui_common/objects/apns.py
index c39f667f..feb74e7d 100644
--- a/common/ui_common/objects/apns.py
+++ b/common/ui_common/objects/apns.py
@@ -54,8 +54,9 @@ class APNs:
def apns_case(self, data: {}):#接受一个data的参数,类型为字典
self.driver.implicitly_wait(10)
self._create(data)
- if data["isCheckItem"] == "True":
- pass
+ if "isCheckItem" in data.keys():
+ if data["isCheckItem"] == "True":
+ pass
else:
self._modify(data)
self._delete(data)
@@ -138,13 +139,17 @@ class APNs:
self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(item) # 输入item内容
self.driver.find_element(By.XPATH, apn_ObjectPagen_SaveItem_posXpath).click() # 点击保存
else:
- if data["isCheckItem"] == "True":
+ if "isCheckItem" in data.keys():
self.driver.find_element(By.XPATH, apn_ObjectPage_addItem_posXpath).click() # 添加item按钮
- self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(data["item"]) # 输入item内容
- assert self.driver.find_element(By.XPATH, '//div[@class="MuiFormHelperText-root css-koslx8"]').text == "Invalid domain name format."
+ for char in data["item"]:
+ self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(char) # 输入item内容
+ time.sleep(0.1)
+ assert self.driver.find_element(By.XPATH, '//div[@class="apn-object-expression"]/div[2]').text == "Input error, illegal format"
else:
self.driver.find_element(By.XPATH, apn_ObjectPage_addItem_posXpath).click()#添加item按钮
- self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(self.random_item)#输入item内容
+ for char in self.random_item:
+ self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(char)#输入item内容
+ time.sleep(0.1)
self.driver.find_element(By.XPATH, apn_ObjectPagen_SaveItem_posXpath).click()#点击保存
# self.driver.find_element(By.XPATH,
# object_page_ln_select_statistics_input_posXpath).click() # 选择statistics
@@ -456,7 +461,9 @@ class APNs:
# 新建item
self.random_item = self.my_random.random_apns()
self.driver.find_element(By.XPATH, apn_ObjectPage_addItem_posXpath).click() # 添加item按钮
- self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(self.random_item) # 输入item内容
+ for char in self.random_item:
+ self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(char) # 输入item内容
+ time.sleep(0.1)
self.driver.find_element(By.XPATH, apn_ObjectPagen_SaveItem_posXpath).click()
#2.上传文件按钮是否是不可点击的
import_elem = apn_ObjectDetailPage_pleaseUpload_posXpath
@@ -478,7 +485,8 @@ class APNs:
self.driver.find_element(By.XPATH,apn_ObjectPage_InputName_posXpath).send_keys(self.random_name)#重新输入name
self.driver.find_element(By.XPATH,apn_ObjectPage_editItem_posXpath).click() #编辑item按钮
self.objects_po.clear_Name(path=apn_ObjectPage_inputItem_posXpath) # 清除item
- self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(self.my_random.random_apns()) # 重新输入item
+ for char in self.my_random.random_apns():
+ self.driver.find_element(By.XPATH, apn_ObjectPage_inputItem_posXpath).send_keys(char) # 重新输入item
self.driver.find_element(By.XPATH, apn_ObjectPagen_SaveItem_posXpath).click() # 点击保存
#确认修改
self.object_page_save()
@@ -2119,7 +2127,7 @@ if __name__ == '__main__':
chrome_option = webdriver.ChromeOptions()
driver = MyWebDriver(
# command_executor="http://192.168.64.11:4444",
- command_executor="http://192.168.39.89:4444",
+ command_executor="http://192.168.64.26:4444",
options=chrome_option
)
apn = APNs(demo_fixture=driver)
diff --git a/common/ui_common/objects/objects_public_operations.py b/common/ui_common/objects/objects_public_operations.py
index 3900f5f2..d7751bd0 100644
--- a/common/ui_common/objects/objects_public_operations.py
+++ b/common/ui_common/objects/objects_public_operations.py
@@ -69,8 +69,8 @@ def download_files():
driver.find_element(By.XPATH, "//*[@id='details-button']").click()
driver.find_element(By.XPATH, "//*[@id='proceed-link']").click()
# 输入账户和密码
- 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="root"]/div/div[2]/div/div[1]/input').send_keys(loginout_parse.get("ui_account_1", "username"))
+ driver.find_element(By.XPATH, '//*[@id="root"]/div/div[2]/div/div[2]/input').send_keys(loginout_parse.get("ui_account_1", "passwd"))
driver.find_element(By.XPATH, '//*[@id=":r0:"]').click()
myloginout = LogInOut
# 消除右上角弹框
diff --git a/common/ui_common/objects/ports.py b/common/ui_common/objects/ports.py
index 9ab12405..671c0713 100644
--- a/common/ui_common/objects/ports.py
+++ b/common/ui_common/objects/ports.py
@@ -263,14 +263,14 @@ class Ports:
# 点击items "+"按钮
self.driver.find_element(By.XPATH, port_ObjectDetailPage_item_addButton_posXpath).click() # 点击“+”按钮
if single_or_multi == 1: # 一个Item一条数据
+ for char in str(item_value):
# 在空内容的输入框中,输入新增的数据
- self.driver.find_element(By.XPATH, port_ObjectDetailPage_itemValueInput_poXpath ).send_keys(
- item_value) # 于Item value输入框键入上述item_value
+ self.driver.find_element(By.XPATH, port_ObjectDetailPage_itemValueInput_poXpath).send_keys(char) # 于Item value输入框键入上述item_value
+ time.sleep(0.1)
else: # 一个Item多条数据
for single_item_value in item_value:
- self.driver.find_element(By.XPATH,
- "({})[last()]".format(port_ObjectDetailPage_itemValueInput_poXpath)).send_keys(
- single_item_value) # 于Item value输入框键入上述item_value
+ for char in single_item_value:
+ self.driver.find_element(By.XPATH, "({})[last()]".format(port_ObjectDetailPage_itemValueInput_poXpath)).send_keys(char) # 于Item value输入框键入上述item_value
if single_item_value == item_value[-1]:
break
else:
@@ -338,7 +338,8 @@ class Ports:
port_item_input_xpath = '//input[@class="MuiInput-input css-1u0jcuo"]'
self.driver.find_element(By.XPATH, port_item_input_xpath).clear()
# 清空后键入新数据
- self.driver.find_element(By.XPATH, port_item_input_xpath).send_keys(new_value)
+ for char in str(new_value):
+ self.driver.find_element(By.XPATH, port_item_input_xpath).send_keys(char)
# 保存
port_item_save_btn_xpath = port_ObjectDetailPage_itemSaveButton_poXpath
self.driver.find_element(By.XPATH, port_item_save_btn_xpath).click()
@@ -2613,6 +2614,15 @@ class Ports:
print("first row not exist")
total_value = self.driver.find_element(By.XPATH, main_listPage_object_total_value_posXpath).text
assert total_value == "Total: 1", "total数目不符"
+ 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"]').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()
assert self.driver.find_element(By.XPATH, port_listPage_object_first_row_uuid_posXpath).text == self.objects_po.table_dict["UUID"]
elif search_type == "Description":
search_value = self.objects_po.table_dict["Description"][:40]
@@ -2630,6 +2640,15 @@ class Ports:
print("first row not exist")
total_value = self.driver.find_element(By.XPATH, main_listPage_object_total_value_posXpath).text
assert total_value == "Total: 1", "total数目不符"
+ 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"]').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()
assert self.driver.find_element(By.XPATH, port_listPage_object_first_row_uuid_posXpath).text == self.objects_po.table_dict["UUID"]
elif search_type == "Details":
item_data = data["Items"][0].split("-")
@@ -2649,6 +2668,15 @@ class Ports:
print("first row not exist")
total_value = self.driver.find_element(By.XPATH, main_listPage_object_total_value_posXpath).text
assert total_value == "Total: 1", "total数目不符"
+ 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"]').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()
assert self.driver.find_element(By.XPATH, port_listPage_object_first_row_uuid_posXpath).text == self.objects_po.table_dict["UUID"]
# self.driver.find_element(By.XPATH,'//*[@id="multilineAll-_MultilineTableCell_ElTableBody_ElTable_Objects_port_Home_App_anonymousComponent"]').click()
# self.driver.find_element(By.XPATH, listPage_item_search_text_posXpath).send_keys(item_data[0] + Keys.ENTER)
@@ -2976,9 +3004,9 @@ class Ports:
def fuzzy_search(self,data):
self._create(data)
self.objects_po.extract_ele()
- self._just_goto_portsPage()
+ self._goto_portsPage()
self.special_search(data)
- self._just_goto_portsPage()
+ self._goto_portsPage()
self._del(data)
def policy_reference_count_check(self,data):
@@ -3022,18 +3050,18 @@ if __name__ == '__main__':
# driver = download_files()
driver = MyWebDriver(
# command_executor="http://192.168.64.11:4444",
- command_executor="http://192.168.39.89:4444",
+ command_executor="http://192.168.64.26:4444",
options=chrome_option
)
port = Ports(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()
@@ -3041,18 +3069,18 @@ if __name__ == '__main__':
# profile_pub = ProfilesPublicOperations(driver)
# profile_pub.change_vsys(vsys_name='UIAutoTestVsys')
# profile_pub.change_vsys(vsys_name="Vsys2test")
- port._import_many_items(data=
+ port.port_case(data=
{
- "ids": "编辑时导入item",
+ "ids": "ID作为搜索条件进行模糊查询-T074-1",
"Model": "create",
"Type": 0,
- "Search type": "Name",
- "Name": "测试大量导入",
+ "Name": "",
+ "Search type": "UUID",
"Items": [
- "80->",
+ "[random]->"
],
"Description": "",
- "file_name": "port大量导入10万条数据.txt"
+ "Subordinate Objects": ""
},)
time.sleep(3)
driver.quit() \ No newline at end of file
diff --git a/page_element/objects_element_position.py b/page_element/objects_element_position.py
index 46981cd3..18419a14 100644
--- a/page_element/objects_element_position.py
+++ b/page_element/objects_element_position.py
@@ -1472,7 +1472,7 @@ flagGroup_ObjectDetailPage_subitem_add_posXpath = '//div[@class="mt-[10px] flex
# 对象详情页
port_ObjectDetailPage_nameInput_posXpath = '//input[@class="MuiInput-input css-fqt4w4"]' # Name输入框Xpath!!!!!
port_ObjectDetailPage_item_addButton_posXpath = '//i[@class="iconfont icon-Create1 font-[700]"]' # item下"+"按钮!!!!!
-port_ObjectDetailPage_itemValueInput_poXpath = '//div[@class="MuiInput-root MuiInput-variantOutlined MuiInput-colorNeutral MuiInput-sizeMd MuiInput-formControl css-grqzrl"]/input' # item 下value输入框Xpath!!!!!
+port_ObjectDetailPage_itemValueInput_poXpath = '//input[@class="MuiInput-input css-1u0jcuo"]' # item 下value输入框Xpath!!!!!
port_ObjectDetailPage_itemSaveButton_poXpath = '//i[@class="operate-icon iconfont icon-save"]' # item 下value保存按钮Xpath!!!!!
port_ObjectDetailPage_item_search_posId = acc_ObjectDetailPage_item_search_posXpath # item 下搜索框id
port_ObjectDetailPage_item_search_posXpath = '//input[@class="MuiInput-input css-za5rna"]' # item 下搜索框xpath!!!!!
@@ -1552,7 +1552,7 @@ port_ObjectDetailPage_okButton_yes_posXpath = acc_ObjectDetailPage_okButton_yes_
port_groupObjectDetailPage_excludeObjects_search_posXpath = '//div[@class="port-object-excluded_sub_object_uuids"]//input'
port_groupObjectDetailPage_subordinateObjects_search_posXpath = '//div[@class="port-object-included_sub_object_uuids"]//input'
port_ObjectGroupDetailPage_subObjects_addButton_normalAdd_posXpath = '//div[@class="port-object-included_sub_object_uuids"]//button' # Subordinate Objects 下无数据新增时"+"按钮Xpath
-port_ObjectGroupDetailPage_subObjects_addButton_newAdd_posXpath = '//div[@class="port-object-included_sub_object_uuids"]//i[@class="iconfont icon-Create1 text-[18px] font-[700] text-[--color-primary] cursor-pointer"]' # Subordinate Objects 下有数据新增时"+"按钮Xpath
+port_ObjectGroupDetailPage_subObjects_addButton_newAdd_posXpath = '//div[@class="port-object-included_sub_object_uuids"]//i' # Subordinate Objects 下有数据新增时"+"按钮Xpath
port_ObjectGroupDetailPage_subObjects_toggleDraw_addButton_posXpath = '//div[@class="px-[12px] py-[4px] flex"]/button' # Ports侧滑窗口的"+"按钮
port_ObjectGroupDetailPage_subObjects_toggleDraw_addButton_port_posXpath = objectPage_group_sub_object_add_new_select_button_posXpath # Ports侧滑窗口的"+"按钮下的Port
port_ObjectGroupDetailPage_subObjects_subCreatePortDrawer_nameInput_posXpath = '(//input[@class="MuiInput-input css-fqt4w4"])[2]' # 侧滑子Create Ports页面Name input Xpath
diff --git a/testdata/ui_data/objects_data/Ports/base_ports.json b/testdata/ui_data/objects_data/Ports/base_ports.json
index c67ad610..b30bd9db 100644
--- a/testdata/ui_data/objects_data/Ports/base_ports.json
+++ b/testdata/ui_data/objects_data/Ports/base_ports.json
@@ -154,7 +154,7 @@
"Model": "create",
"Type": 0,
"Name": "",
- "Search type": "ID",
+ "Search type": "UUID",
"Items": [
"[random]->"
],
diff --git a/testdata/ui_data/objects_data/apns.json b/testdata/ui_data/objects_data/apns.json
index 1c570da7..0e1d678b 100644
--- a/testdata/ui_data/objects_data/apns.json
+++ b/testdata/ui_data/objects_data/apns.json
@@ -10,7 +10,6 @@
"importCorrectFile":"False",
"isCheckName":"False",
"isCheckObjectFrame":"False"
-
},
{
"ids": "APN Group的增删改查",