def get_into_group_chat_page(name):
        """进入群聊聊天会话页面"""

        mp = MessagePage()
        mp.wait_for_page_load()
        # 点击 +
        mp.click_add_icon()
        # 点击发起群聊
        mp.click_group_chat()
        scg = SelectContactsPage()
        times = 15
        n = 0
        # 重置应用时需要再次点击才会出现选择一个群
        while n < times:
            # 等待选择联系人页面加载
            flag = scg.wait_for_page_load()
            if not flag:
                scg.click_back()
                time.sleep(2)
                mp.click_add_icon()
                mp.click_group_chat()
            else:
                break
            n += 1
        scg.click_select_one_group()
        sog = SelectOneGroupPage()
        # 等待“选择一个群”页面加载
        sog.wait_for_page_load()
        # 选择一个普通群
        sog.selecting_one_group_by_name(name)
        gcp = GroupChatPage()
        gcp.wait_for_page_load()
 def go_to_group_double(group_name):
     """从消息列表进入双机群聊,前提:已经存在双机群聊"""
     mess = MessagePage()
     mess.wait_for_page_load()
     mess = MessagePage()
     mess.wait_for_page_load()
     # 点击 +
     mess.click_add_icon()
     # 点击 发起群聊
     mess.click_group_chat()
     # 选择联系人界面,选择一个群
     sc = SelectContactsPage()
     times = 15
     n = 0
     # 重置应用时需要再次点击才会出现选择一个群
     while n < times:
         flag = sc.wait_for_page_load()
         if not flag:
             sc.click_back()
             time.sleep(2)
             mess.click_add_icon()
             mess.click_group_chat()
             sc = SelectContactsPage()
         else:
             break
         n = n + 1
     time.sleep(3)
     sc.click_select_one_group()
     # # 群名
     # group_name = Preconditions.get_group_chat_name_double()
     # 获取已有群名
     sog = SelectOneGroupPage()
     sog.wait_for_page_load()
     sog.click_search_group()
     time.sleep(2)
     sog.input_search_keyword(group_name)
     time.sleep(2)
     if not sog.is_element_exit("群聊名"):
         raise AssertionError("没有找到双机群聊,请确认是否创建")
     sog.click_element_("群聊名")
     gcp = GroupChatPage()
     gcp.wait_for_page_load()
    def enter_single_chat_page(name):
        """进入单聊聊天会话页面"""

        mp = MessagePage()
        mp.wait_for_page_load()
        # 点击 +
        mp.click_add_icon()
        # 点击“新建消息”
        mp.click_new_message()
        slc = SelectLocalContactsPage()
        slc.wait_for_page_load()
        # 进入单聊会话页面
        slc.selecting_local_contacts_by_name(name)
        bcp = BaseChatPage()
        if bcp.is_exist_dialog():
            # 点击我已阅读
            bcp.click_i_have_read()
        scp = SingleChatPage()
        # 等待单聊会话页面加载
        scp.wait_for_page_load()
 def make_already_have_my_group(reset=False):
     """确保有群,没有群则创建群名为mygroup+电话号码后4位的群"""
     # 消息页面
     Preconditions.make_already_in_message_page(reset)
     mess = MessagePage()
     mess.wait_for_page_load()
     # 点击 +
     mess.click_add_icon()
     # 点击 发起群聊
     mess.click_group_chat()
     # 选择联系人界面,选择一个群
     sc = SelectContactsPage()
     times = 15
     n = 0
     # 重置应用时需要再次点击才会出现选择一个群
     while n < times:
         flag = sc.wait_for_page_load()
         if not flag:
             sc.click_back()
             time.sleep(2)
             mess.click_add_icon()
             mess.click_group_chat()
             sc = SelectContactsPage()
         else:
             break
         n = n + 1
     time.sleep(3)
     sc.click_select_one_group()
     # 群名
     group_name = Preconditions.get_group_chat_name()
     # 获取已有群名
     sog = SelectOneGroupPage()
     sog.wait_for_page_load()
     sog.click_search_group()
     time.sleep(2)
     sog.input_search_keyword(group_name)
     time.sleep(2)
     if sog.is_element_exit("群聊名"):
         current_mobile().back()
         time.sleep(2)
         current_mobile().back()
         return
     current_mobile().back()
     time.sleep(2)
     current_mobile().back()
     sog.click_back()
     time.sleep(2)
     sc.click_back()
     mess.wait_for_page_load()
     # 点击 +
     mess.click_add_icon()
     # 点击 发起群聊
     mess.click_group_chat()
     # 从本地联系人中选择成员创建群
     sc.click_local_contacts()
     time.sleep(2)
     slc = SelectLocalContactsPage()
     a = 0
     names = {}
     while a < 3:
         names = slc.get_contacts_name()
         num = len(names)
         if not names:
             raise AssertionError("No contacts, please add contacts in address book.")
         if num == 1:
             sog.page_up()
             a += 1
             if a == 3:
                 raise AssertionError("联系人只有一个,请再添加多个不同名字联系人组成群聊")
         else:
             break
     # 选择成员
     for name in names:
         slc.select_one_member_by_name(name)
     slc.click_sure()
     # 创建群
     cgnp = CreateGroupNamePage()
     cgnp.input_group_name(group_name)
     cgnp.click_sure()
     # 等待群聊页面加载
     GroupChatPage().wait_for_page_load()
 def build_one_new_group_with_number(puhone_number, group_name):
     """新建一个指定成员和名称的群,如果已存在,不建群"""
     # 消息页面
     mess = MessagePage()
     mess.wait_for_page_load()
     # 点击 +
     mess.click_add_icon()
     # 点击 发起群聊
     mess.click_group_chat()
     # 选择联系人界面,选择一个群
     sc = SelectContactsPage()
     times = 15
     n = 0
     # 重置应用时需要再次点击才会出现选择一个群
     while n < times:
         flag = sc.wait_for_page_load()
         if not flag:
             sc.click_back()
             time.sleep(2)
             mess.click_add_icon()
             mess.click_group_chat()
             sc = SelectContactsPage()
         else:
             break
         n = n + 1
     time.sleep(3)
     sc.click_select_one_group()
     # 群名
     # group_name = Preconditions.get_group_chat_name()
     # 获取已有群名
     sog = SelectOneGroupPage()
     sog.wait_for_page_load()
     sog.click_search_group()
     time.sleep(2)
     sog.input_search_keyword(group_name)
     time.sleep(2)
     if sog.is_element_exit("群聊名"):
         current_mobile().back()
         time.sleep(2)
         current_mobile().back()
         return True
     current_mobile().back()
     time.sleep(2)
     current_mobile().back()
     current_mobile().back()
     time.sleep(2)
     current_mobile().back()
     time.sleep(2)
     # 点击 +
     mess.click_add_icon()
     # 点击 发起群聊
     mess.click_group_chat()
     # 添加指定电话成员
     time.sleep(2)
     sc.input_search_keyword(puhone_number)
     time.sleep(2)
     sog.click_text("tel")
     time.sleep(2)
     # 从本地联系人中选择成员创建群
     sc.click_local_contacts()
     time.sleep(2)
     slc = SelectLocalContactsPage()
     SelectContactsPage().click_one_contact_631("飞信电话")
     # a = 0
     # names = {}
     # while a < 3:
     #     names = slc.get_contacts_name()
     #     num = len(names)
     #     if not names:
     #         raise AssertionError("No contacts, please add contacts in address book.")
     #     if num == 1:
     #         sog.page_up()
     #         a += 1
     #         if a == 3:
     #             raise AssertionError("联系人只有一个,请再添加多个不同名字联系人组成群聊")
     #     else:
     #         break
     # # 选择成员
     # for name in names:
     #     slc.select_one_member_by_name(name)
     slc.click_sure()
     # 创建群
     cgnp = CreateGroupNamePage()
     cgnp.input_group_name(group_name)
     cgnp.click_sure()
     # 等待群聊页面加载
     GroupChatPage().wait_for_page_load()
     return False