TestComplete Tutorial 9 - Mouse Actions and Mouse Wheel Events
TestComplete provides mouse actions and mouse wheel events.
Mouse Actions
To simulate clicks, double-clicks, dragging and hovering (hot-tracking) operations, each onscreen object provides the following methods:
- Click( ) - Simulates a single click performed with the left mouse button.
- ClickR( ) - Simulates a single click performed with the right mouse button.
- ClickM( ) - Simulates a single click performed with the middle mouse button.
- DblClick( ) - Simulates a double click performed with the middle mouse button.
- DblClickR( ) - Simulates a double click performed with the middle mouse button.
- DblClickM( ) - Simulates a double click performed with the middle mouse button.
- Drag( ) - Simulates a dragging operation performed with the left mouse button.
- DragR( ) - Simulates a dragging operation performed with the right mouse button.
- DragM( ) - Simulates a dragging operation performed with the middle mouse button.
- HoverMouse( ) - Simulates moving the mouse pointer to the specified position within an object.
Each of these actions have parameters that specify window-related coordinates of the event.
You can also simulate mouse clicks by using the MouseDown and MouseUp methods of the Desktop object.
Examples -
Example to Click on button -
btnStart = "name mapping of btn";
btnStart.Click( );
Example to DblClick on button -
btnStart.DblClick( );
Mouse Wheel Events
TestComplete records user actions over tested applications, including the mouse wheel rotation, as object operations.
For example, if you rotate the mouse wheel to scroll the contents displayed in a text editor, TestComplete will record the scrolling as modifying the VScroll.Pos property of the editor window.
The VScroll property of the window object provides access to the vertical scroll bar and its Pos property specifies the scroll bar position.
If a tested object does not have a vertical scroll bar, TestComplete uses the MouseWheel action.
To simulate mouse wheel rotation from a script routine, call the OnScreenObject.MouseWheel method with proper parameters.
Example -
Sys.Process("Notepad").Window("Notepad", "*").Window("Edit", "").MouseWheel(-1);
Note: TestComplete does not record mouse wheel actions over web pages.
Comments
Post a Comment