回放低级别鼠标和键盘操作

鼠标和键盘操作的低级别回放能增强对用户操作事件的控制。 例如,Functional Tester 当前支持 TestObject.click(),此处的单击包括多个低级别操作,包括移动鼠标、按下鼠标左键以及松开鼠标左键。可以使用该功能回放鼠标单击过程的个别部分。

低级别回放还支持鼠标滚轮滚动。

您可能想要使用低级别回放来克服产品限制或模糊的鼠标或键盘操作。例如,在绘画程序中的画布上画圆圈,Functional Tester 不支持复杂的圆圈拖动,但是您可以使用 drag() 方法来画直线。要克服模糊的鼠标或键盘操作,您可以使用低级别回放来回放画圆圈的鼠标操作。

RootTestObject 类包含两种方法:

SubitemFactory 上的构造 LowLevelEvent 的工厂方法包括:

并行方法针对鼠标中键和右键。延迟事件保证至少延迟指定的毫秒数(考虑系统处理前一事件所需的时间)。

用来在画布的左上部分中画字母 V 的 Functional Tester Java™ 脚本编制示例:

// This routine will draw a "V" in the upper left portion
// of the drawing canvas.
// First a point in the upper left corner will be clicked, the left mouse
// button will be held down for the duration of the action, the mouse
// will be moved to the right and down, then to the right and back up,
// and finally the left mouse button will be released.
Rectangle screenRect =
   (Rectangle) drawingWindow().getProperty(".screenRectangle");
Point origin = new Point(screenRect.x + 5, screenRect.y + 5);
LowLevelEvent llEvents[] = new LowLevelEvent[7];
llEvents[0] = mouseMove(atPoint(origin.x, origin.y));
llEvents[1] = leftMouseButtonDown();
// insert a delay to provide the SUT with time to respond
// to the events being delivered to it.
llEvents[2] = delay(250);
llEvents[3] = mouseMove(atPoint(origin.x + 25, origin.y + 50));
llEvents[4] = delay(250);
llEvents[5] = mouseMove(atPoint(origin.x + 50, origin.y));
llEvents[6] = leftMouseButtonUp();
getRootTestObject().emitLowLevelEvent(llEvents);

用来测试 TrackBar 控件以及确认该控件会响应鼠标滚轮事件的 Functional Tester VB.NET 脚本编制示例:

' This will test a TrackBar control to make sure
' that it responds to mouse wheel events.
TrackBar1Slider().Click(AtPoint(0, 0))
' Create a Low Level Event representing scrolling
' the mouse wheel down 25 clicks.
Dim ScrollDown As LowLevelEvent = MouseWheel(-25)
GetRootTestObject().EmitLowLevelEvent(ScrollDown)
' Verify The Results.

反馈