def cancel_delete_label_groups(self, *groups): """ 删除指定分组点击取消 :param groups: 要删除的分组名称数组 :return: """ from pages import LableGroupDetailPage for name in groups: if isinstance(name, (list, tuple)) and len(name) > 0: name = name[0] if self.click_label_group(name): detail = LableGroupDetailPage() try: self.click_element(['xpath', '//*[@text="知道了"]'], 1) except: pass detail.open_setting_menu() detail.click_delete_label_menu() detail.click_cancel() self.click_back() try: self.click_element(['xpath', '//*[@text="知道了"]'], 1) except: pass self.click_back() self.wait_for_page_load()
def remove_group_members(self, group, *members): from pages import LableGroupDetailPage if self.click_label_group(group): detail = LableGroupDetailPage() try: self.click_element(['xpath', '//*[@text="知道了"]'], 1) except: pass detail.open_setting_menu() detail.remove_members(*members) self.click_back() try: self.click_element(['xpath', '//*[@text="知道了"]'], 1) except: pass detail.wait_for_page_load() try: self.click_element(['xpath', '//*[@text="知道了"]'], 1) except: pass self.click_back() self.wait_for_page_load()
def rename_label_group(self, old_name, new_name): """ 重命名分组 :param old_name: 要修改的分组 :param new_name: 将赋予的分组名 :return: """ from pages import LableGroupDetailPage if self.click_label_group(old_name): detail = LableGroupDetailPage() try: self.click_element(['xpath', '//*[@text="知道了"]'], 1) except: pass detail.open_setting_menu() detail.rename_group_name(new_name) import time time.sleep(2) self.click_back() detail.wait_for_page_load() actual = detail.get_group_name() self.click_back() self.wait_for_page_load() return actual
def delete_all_label(self): """ 一键删除全部分组 :return: """ from pages import LableGroupDetailPage # groups=self.get_element(self.__class__.__locators['已建分组列表1']) while self.is_element_present(locator='已建分组列表1'): self.click_element(self.__class__.__locators['已建分组列表1']) detail = LableGroupDetailPage() detail.click_cancel() detail.open_setting_menu() lable_setting=LabelSettingMenu() lable_setting.click_delete_label_menu() lable_setting.click_delete() time.sleep(2)
def delete_group(self): """ 删除指定分组(默认删除排列第一的分组) :return: """ from pages import LableGroupDetailPage self.click_element(self.__class__.__locators['已建分组列表1']) time.sleep(2) detail = LableGroupDetailPage() detail.click_cancel() detail.open_setting_menu() lable_setting=LabelSettingMenu() time.sleep(1) lable_setting.click_delete_label_menu() time.sleep(1) lable_setting.click_delete() time.sleep(2)
def delete_all_label(self): """ 一键删除全部分组 :return: """ from pages import LableGroupDetailPage groups = self.get_elements(self.__locators['分组根节点'])[1:] while groups: groups[0].click() # 删除标签 detail = LableGroupDetailPage() try: self.click_element(['xpath', '//*[@text="我知道了"]'], 1) except: pass detail.open_setting_menu() detail.click_delete_label_menu() detail.click_delete() self.wait_for_page_load() # 刷新group groups = self.get_elements(self.__locators['分组根节点'])[1:]