谁偷偷删了你的微信?用Python分分钟揪出来( 四 )

接着尝试着给对方转账,如果好友关系正常,就会跳出一个支付页面让输入密码 。
def __judge_is_friend(self, weixin_id, weixin_name):        """        判断是不是微信好友        :param weixin_id: 微信号        :return:        """        # 尝试给好友转账,设置一个小额度,以防止刷脸直接支付了        # 如果对方是你的好友,接下来会让你输入密码,关掉页面就行了        # 如果对方不是你的好友,会提示不是你的好友,不能继续操作了        # 5、点击好友界面的+按钮        self.poco(self.id_chat_more_button).click()        # 6、点击转账按钮        self.poco(self.id_chat_more_container).offspring(text=self.text_chat_transfer_account_text).click()        # 7、输入金额        self.poco(self.id_transfer_account_input).set_text(self.money)        # 8、点击转账按钮        self.poco(self.id_transfer_account_container).offspring(text=self.text_chat_transfer_account_text).click()如果是僵尸粉,应用会弹出一个警告对话框,提示你不是收款方好友,没法完成转账的操作 。

谁偷偷删了你的微信?用Python分分钟揪出来

文章插图
 
通过警告对话框是否存在,就可以判断好友关系是否正常 。非正常的好友关系,包含:僵尸粉、对方账号异常等 。
# 10.弹出警告对话框# 弹出好友关系不正常if element_transfer_account_result_button:     # 提示内容     ransfer_account_result_tips = self.poco(self.id_transfer_account_result_tips).get_text()     if self.text_friend_no_tips in transfer_account_result_tips:         print('注意!%s已经把你拉黑了!!!' % weixin_name)         self.friend_black_list.append({                    'id': weixin_id,                    'nickName': weixin_name                })         write_to_file(self.path_black_list, 'id:%s,nickName:%s' % (weixin_id, weixin_name))     elif self.text_friend_limit_tips in transfer_account_result_tips:         print('%s账号收到限制!!!' % weixin_name)         write_to_file(self.path_account_limit, 'id:%s,nickName:%s' % (weixin_id, weixin_name))     elif self.text_friend_is_norm in transfer_account_result_tips:         print('%s好友关系不正常!!!' % weixin_name)         write_to_file(self.path_relationship_unnormal, 'id:%s,nickName:%s' % (weixin_id, weixin_name))     # 点击确认按钮     element_transfer_account_result_button.click()     # 返回到主页面     self.__back_to_home()else:     # 包含正常好友关系和对方账号限制的情况     print('好友关系正常')     self.__back_to_home()最后,模拟点击手机的返回键,一直回退到微信主界面 。
def __back_to_home(self):        """        回退到主界面        :return:        """        print('准备回退到主界面')        home_tips = ['微信', '通讯录', '发现', '我']        while True:            keyevent('BACK')            is_home = False            # 判断是否到达首页            if self.poco(text=home_tips[0]).exists() and self.poco(text=home_tips[1]).exists() and self.poco(                    text=home_tips[2]).exists() and self.poco(text=home_tips[3]).exists():                is_home = True            if is_home:                print('已经回到微信首页~')                break


推荐阅读