wlcom GUI Automation
在KylinOS V11 Desktop(银河麒麟桌面操作系统 V11)上使用wlcom的wlcctrl命令进行GUI测试自动化时,请使用此技能。
基本规则
V11使用Wayland + UKUI + wayland-compositor/wlcom;不应假设X11工具具有权威性。优先使用wlcctrl进行窗口发现、截图、指针移动、点击、按键和窗口放置。始终在计算指针坐标之前检查缩放比例。wlcctrl --mousemove是绝对的,尽管手册页上说是位移。在测试的V11机器上,--mousemove输入必须是逻辑坐标×输出缩放;--getmouselocation返回逻辑坐标。--windowmove -x/-y使用逻辑坐标;不应乘以缩放。当前wlcctrl v1.0.0帮助/手册显示截图支持,但没有录制子命令。如果需要录制,请检查其他wlcom工具或使用批准的录制器。
快速工作流程
命令 -v wlcctrl
wlcctrl --version
wlcctrl --outputs
wlcctrl --getdisplaygeometry
gsettings get org.ukui.SettingsDaemon.plugins.xsettings scaling-factor 2>/dev/null || true
wlcctrl --list
wlcctrl --search ''
wlcctrl --getactivewindow
wlcctrl --getwindowgeometry
wlcctrl --windowcapture --path /tmp/window.png
logical_screen_x = window_x + screenshot_relative_x
logical_screen_y = window_y + screenshot_relative_y
mousemove_x = round(logical_screen_x
scale)
mousemove_y = round(logical_screen_y scale)
wlcctrl --mousemove ,
wlcctrl --getmouselocation
wlcctrl --mousebutton 1
wlcctrl --windowcapture --path /tmp/after.png
助手脚本
此技能包括脚本目录下的脚本:
scripts/wlcctrl-info.sh — 打印版本、输出、显示几何、缩放候选、活动窗口和鼠标位置。
scripts/wlcctrl-window-click.sh [button] — 点击窗口截图中的相对点。
scripts/wlcctrl-move-window.sh — 使用逻辑坐标移动窗口并验证几何。
在运行之前,请解析脚本路径相对于此SKILL.md目录。
常用命令
输出和缩放
wlcctrl --outputs
wlcctrl --getdisplaygeometry
查找:物理大小:300x190 mm
缩放:1.750000
模式:2880 x 1800 @ 90
位置:0, 0
xdpyinfo可能会报告Xwayland逻辑DPI(例如96x96),不应单独用于Wayland坐标转换。
窗口
wlcctrl --list
wlcctrl --search ''
wlcctrl --getactivewindow
wlcctrl --getwindowname
wlcctrl --getwindowgeometry
wlcctrl --windowactivate
wlcctrl --windowmove -x 0 -y 0
wlcctrl --windowsize -w 800 -h 600
截图
wlcctrl --windowcapture --path /tmp/window.png
wlcctrl --fullscreencapture --path /tmp/full.png
wlcctrl --setarea --path /tmp/area.png
wlcctrl --workspacecapture --path /tmp/workspace.png
键盘和指针
wlcctrl --key ctrl+alt+t
wlcctrl --keystring 'text to type'
wlcctrl --mousebutton 1
wlcctrl --mousepress 1 --mouserelease 1
wlcctrl --scroll -y 10
wlcctrl --getmouselocation
对于拖动操作,移动到开始,按下,移动到结束,释放。记住--mousemove坐标是缩放的绝对坐标。
坐标配方
给定:输出缩放 = S
窗口几何 = (WX, WY) WIDTH x HEIGHT
目标点在捕获的窗口图像中 = (RX, RY)
则:
logical_x = WX + RX
logical_y = WY + RY
mousemove_x = round(logical_x
S)
mousemove_y = round(logical_y S)
运行:
wlcctrl --mousemove "${mousemove_x},${mousemove_y}"
wlcctrl --getmouselocation # 应该在logical_x,logical_y附近
wlcctrl --mousebutton 1
已测试的示例
在一个V11机器上测试:输出eDP-1,缩放1.75
计算器窗口几何:(607, 176) 432 x 628 = 窗口截图中心(376,593)
逻辑目标(983,769)
--mousemove输入约(1720,1346)
--getmouselocation返回约(983,769)
测试模式
对于可靠的GUI自动化测试:
规范化窗口:激活并可选地移动到(0,0)。
捕获窗口。
从截图坐标识别目标控件。
通过缩放的绝对--mousemove + --mousebutton点击。
再次捕获并通过视觉或OCR/图像分析验证。
记录每个wlcctrl命令及其输出以实现可复制性。
安全
除非用户明确要求,否则避免使用--windowclose和--windowkill。
在发送破坏性按键之前,请确认目标窗口UUID/标题。
在可能的情况下,将测试截图/日志存储在项目artifacts/目录下。