保留指定人员的聊天记录文本信息

技术方案:基于Airtest 获取某信指定人员的聊天记录文本信息

基于

Airtest IDE 连接 夜游神模拟器 自动化UI测试_javaDB_EAD的专栏-CSDN博客

编写案例核心代码如下:

# -*- encoding=utf8 -*-
__author__ = "Administrator"

from airtest.core.api import *

auto_setup(__file__)


from poco.drivers.android.uiautomation import AndroidUiautomationPoco
poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
import win32con
import time


# 唤醒手机
#poco.device.wake()  

keyevent("HOME")
#打开某信
poco("某信").click()
#搜过指定聊天人员
poco(text="javaDB").click()
#获取聊天内容


w,h =poco.get_screen_size()
print(poco.get_screen_size())
#double_click((120,280))
 

category=[]
#获取聊天内容
for answer in poco('com.tencent.mm:id/auk'):
    #answer.long_click()
    x, y = answer.get_position()
    pos = answer.get_position()
    cx = int(x * w)
    cy = int(y * h)
    #print('=============get_position========'+ str(pos)+'---cx:'+str(cx)+'---cy:'+str(cy))
    #double_click((120,280))
    double_click((cx,cy))
    dao = poco("com.tencent.mm:id/dc3")
    sleep(1)
    if dao.exists() :
        category.append(str(dao.get_text()))
        print('=======get_text===================坐标cx:'+str(cx)+'---cy:'+str(cy)+'--聊天文本信息:'+str(dao.get_text()))
    
    #os.system('pause')
    answer.click()
#打印聊天文本信息
print(category)

#点击输入框
poco("com.tencent.mm:id/iki").click()
#输入发送内容
text("myPowerAI你好呀!")
try :
    #发送
    #poco("com.tencent.mm:id/ay5").click()
    poco(text="发送").click()
except Exception:
    print('exception---')
    
    
    

# 回到小程序首页
keyevent("BACK")
keyevent("BACK")
keyevent("BACK")
#sleep(2)
# 断言:进入的页面是否存在“个人中心”文本
#assert(poco(text="个人中心").exists())
# 关闭
stop_app("com.tencent.mm") 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值