SciTech-Automation-UI交互自动化: Microsoft 的 接口自动化测试 : 微信的: LLM(AI/Transformer)的自动应答系统

用LLM +Python 实现微信消息的自动应答


先上一个"Alpha"版本的,以csv关键词匹配方式描述应用的,主题逻辑.

!/usr/bin/python3
# coding: utf-8

import pandas as pd
import numpy as np
from uiautomation import windowControl,Menucontrol
from functools import partial, wraps


# read replies data
df = pd.read_csv("应答数据.csv",encoding="gb18030")

# matching answers by keywords from the last one message.
def matcher(last_msg, x):
    ret = None
    if x["关键词"] in last_msg:
        ret = x["应答内容"]
    return ret


# bind the "title" of WeChat's main window
wx = windowControl(
   Name="微信",
   # searchDepth=1
)
print("MainWindow: %r" % (wx,))

# bind it's session ctrl.
wx.SwitchToThiswindow()
hw = wx.ListControl(Name="会话")
print("SessionControl: %r" % (hw,))

# bind it's "Messages" ctrl.
mc=wx.ListControl(Name="消息")

while True:
    # first 4 items as the "searchDepths"
    we = hw.TextControl(searchDepths=4)
    print("Seek unread msg.", we)


    while not we.Exists(0):
        pass

    # if existing unread msg.
    if not bool(we.Name):
        continue

    # click and retrive the unread msg.
    we.Click(simulateMove=False)
    msgs=mc.GetChildren()
    last_msg = msgs[-1] # LAST ONE ONLY
    print("Last One Msg.:%s" % last_msg)

    
    # choose replies msg by keywords
    filter=partial(matcher, last_msg) # #也可用"LLM/AI/Transformer"模型应答
    replies = df.apply(filter, axis=1)
    replies.dropna(axis=0,how="any",inplace=1)
    ar = np.array(replies).tolist()

    if len(ar) == 0: # keywords no replies
        wx.SendKeys("没理解", waitTime=0)
        wx.SendKeys('{Enter}', waitTime=0)
        wx.TextControl(SubName=last_msg[:-5]).RightClick()
        continue

    rms=ar[0].replace('{br}','{Shift}{Enter}')
    wx.SendKeys(rms, waitTime=0)
    wX.SendKeys('{Enter}', waitTime=0)



UI自动化 - 微软UI Automation

--- Original: Niuery Diary

自动化测试平台的 稳定性 非常重要。

无论是接口自动化测试,还是UI自动化测试,
目的之一是为提高产品的稳定性,保证用户体验。

接口自动化测试, 常见的有 Postman, SoapUI, JMeter 等, 这一类网上的资料太多。
本篇内容主题是UI自动化测试,我搜集的常用的UI自动化测试平台:
*「Selenium」: Web应用程序自动化测试框架,开源免费,使用非常广泛;
既支持多种语言的脚本驱动测试,也支持记录与回放的方式测试。

  • 「Appium」: APP(移动应用程序)自动化测试框架,开源免费,使用非常广泛;
    支持多种语言的脚本驱动测试。
  • 「Katalon Studio」: UI自动化测试工具,适用于Web, APP和API测试, 免费。
    基于Selenium和Appium,并提供GUI(图形化界面)和集成的测试功能。
  • 「TestComplete」: 商业UI自动化测试工具,适用于PC, Web, APP和API, 付费。
    功能强大, 提供多种脚本语言和图形化界面,以及灵活的对象识别和回放功能。
  • 「Ranorex」: 商业UI自动化测试工具,适用于PC, Web, APP和API, 付费。
    提供易于使用的录制和回放功能,支持多种编程语言。

总之,对PC应用的UI自动化测试,上述要么免费但仅支持Web应用, 要么就是商业化的。
所以有必要提到主题 --- UIAutomation。


UIAutomation


来看一看微软官方对此的介绍 UIAutomation:
Microsoft UI Automation是适用于Microsoft Windows的Accessibility Framework。
它满足了技术产品和自动化测试框架的需求,通过提供对用户界面(UI)信息的编程访问来实现。
此外,UI Automation还使控件和应用程序开发人员能够使其产品有Assistive Technology。

其它的,Google 或 Microsoft Bing就可以搜索到答案。

posted @ 2024-09-30 12:54  abaelhe  阅读(0)  评论(0编辑  收藏  举报