def tearDown_test_QYTXL_0016(): """恢复环境""" Preconditions.make_already_in_message_page() mp = MessagePage() mp.open_contacts_page() cp = ContactsPage() cp.wait_for_page_load() # 删除指定联系人 cp.click_search_box() name = "陈丹丹" contact_search = ContactListSearchPage() contact_search.wait_for_page_load() contact_search.input_search_keyword(name) if contact_search.is_contact_in_list(name): cp.select_contacts_by_name(name) cdp = ContactDetailsPage() cdp.wait_for_page_load() cdp.click_edit_contact() time.sleep(1) current_mobile().hide_keyboard_if_display() time.sleep(1) cdp.change_delete_number() cdp.click_sure_delete() contact_search.click_back() cp.wait_for_page_load() mp.open_workbench_page() wbp = WorkbenchPage() # 返回工作台 wbp.wait_for_workbench_page_load()
def delete_contact(self, text): """使用此方法前,app进入消息界面""" self.open_contacts_page() from pages import ContactsPage ContactsPage().click_mobile_contacts() if ContactsPage().is_text_present('发现SIM卡联系人'): ContactsPage().click_sim_contact_ok() time.sleep(2) ContactsPage().select_contacts_by_name(text) time.sleep(1) self.click_edit_contact() time.sleep(1) self.hide_keyboard() self.page_up() self.change_delete_number() self.click_sure_delete()
def setUpClass(cls): # 创建联系人 fail_time = 0 import dataproviders while fail_time < 3: try: required_contacts = dataproviders.get_preset_contacts() conts = ContactsPage() preconditions.connect_mobile(REQUIRED_MOBILES['Android-移动']) current_mobile().hide_keyboard_if_display() preconditions.make_already_in_message_page() for name, number in required_contacts: conts.open_contacts_page() if conts.is_text_present("显示"): conts.click_text("不显示") conts.create_contacts_if_not_exits(name, number) return except: fail_time += 1 import traceback msg = traceback.format_exc() print(msg)
def setUpClass(cls): Preconditions.select_mobile('Android-移动') # 导入测试联系人、群聊 fail_time1 = 0 flag1 = False import dataproviders while fail_time1 < 2: try: required_contacts = dataproviders.get_preset_contacts() conts = ContactsPage() current_mobile().hide_keyboard_if_display() Preconditions.make_already_in_message_page() conts.open_contacts_page() try: if conts.is_text_present("发现SIM卡联系人"): conts.click_text("显示") except: pass for name, number in required_contacts: # 创建联系人 conts.create_contacts_if_not_exits(name, number) required_group_chats = dataproviders.get_preset_group_chats() conts.open_group_chat_list() group_list = GroupListPage() for group_name, members in required_group_chats: group_list.wait_for_page_load() # 创建群 group_list.create_group_chats_if_not_exits(group_name, members) group_list.click_back() conts.open_message_page() flag1 = True except: fail_time1 += 1 if flag1: break # 导入团队联系人、企业部门 fail_time2 = 0 flag2 = False while fail_time2 < 5: try: Preconditions.make_already_in_message_page() contact_names = ["大佬1", "大佬2", "大佬3", "大佬4"] Preconditions.create_he_contacts(contact_names) contact_names2 = [("b测算", "13800137001"), ("c平5", "13800137002"), ('哈 马上', "13800137003"), ('陈丹丹', "13800137004"), ('alice', "13800137005"), ('郑海', "13802883296")] Preconditions.create_he_contacts2(contact_names2) department_names = ["测试部门1", "测试部门2"] Preconditions.create_department_and_add_member(department_names) flag2 = True except: fail_time2 += 1 if flag2: break
def setUpClass(cls): Preconditions.select_mobile('Android-移动') # 导入测试联系人、群聊 fail_time1 = 0 flag1 = False import dataproviders while fail_time1 < 3: try: required_contacts = dataproviders.get_preset_contacts() conts = ContactsPage() current_mobile().hide_keyboard_if_display() Preconditions.make_already_in_message_page() conts.open_contacts_page() try: if conts.is_text_present("发现SIM卡联系人"): conts.click_text("显示") except: pass for name, number in required_contacts: # 创建联系人 conts.create_contacts_if_not_exits(name, number) required_group_chats = dataproviders.get_preset_group_chats() conts.open_group_chat_list() group_list = GroupListPage() for group_name, members in required_group_chats: group_list.wait_for_page_load() # 创建群 group_list.create_group_chats_if_not_exits(group_name, members) group_list.click_back() conts.open_message_page() flag1 = True except: fail_time1 += 1 if flag1: break # 导入团队联系人 fail_time2 = 0 flag2 = False while fail_time2 < 5: try: Preconditions.make_already_in_message_page() contact_names = ["大佬1", "大佬2", "大佬3", "大佬4"] Preconditions.create_he_contacts(contact_names) flag2 = True except: fail_time2 += 1 if flag2: break