Files
auto_GUI/test_wechat_click.py
2026-03-04 17:22:39 +08:00

70 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
微信小程序自动化测试脚本
功能:点击桌面微信图标 -> 点击小程序图标 -> 点击一见星球
"""
import pyautogui
import time
# 禁用pyautogui安全区域
pyautogui.FAILSAFE = False
pyautogui.PAUSE = 0.5
# 屏幕尺寸
SCREEN_WIDTH, SCREEN_HEIGHT = pyautogui.size()
print(f"屏幕尺寸: {SCREEN_WIDTH}x{SCREEN_HEIGHT}")
# 微信窗口位置(已知)
WECHAT_WINDOW = {
'x': 877,
'y': 207,
'width': 980,
'height': 710
}
def click(x, y, description=""):
"""点击指定坐标"""
pyautogui.click(x, y)
print(f"点击: ({x}, {y}) - {description}")
time.sleep(0.5)
def main():
print("=" * 50)
print("开始测试:微信 -> 小程序 -> 一见星球")
print("=" * 50)
# 步骤1点击桌面微信图标
print("\n[步骤1] 点击桌面微信图标")
click(288, 162, "桌面微信图标")
time.sleep(3)
# 步骤2点击左侧小程序图标
print("\n[步骤2] 点击左侧小程序图标")
wx = WECHAT_WINDOW['x']
wy = WECHAT_WINDOW['y']
ww = WECHAT_WINDOW['width']
wh = WECHAT_WINDOW['height']
# 小程序图标在左侧边栏
mini_x = wx + int(ww * 0.04)
mini_y = wy + int(wh * 0.22)
click(mini_x, mini_y, f"小程序图标 (窗口内相对位置: {int(ww*0.04)}, {int(wh*0.22)})")
time.sleep(2)
# 步骤3点击一见星球
print("\n[步骤3] 点击一见星球小程序")
planet_x = wx + int(ww * 0.35)
planet_y = wy + int(wh * 0.25)
click(planet_x, planet_y, f"一见星球 (窗口内相对位置: {int(ww*0.35)}, {int(wh*0.25)})")
time.sleep(3)
print("\n" + "=" * 50)
print("测试完成!请检查微信是否正确打开并进入一见星球")
print("=" * 50)
if __name__ == "__main__":
# 等待5秒让用户准备好
print("将在5秒后开始执行请将鼠标移开...")
time.sleep(5)
main()