TestComplete includes special features for simulating mouse and mouse wheel events. You can simulate these events from keyword tests, scripts and low-level procedures. This topic provides detailed information on how to simulate a mouse wheel rotation in your tests. For information on how to simulate other mouse events, see Simulating Mouse Actions.
Basic Concepts
To record and simulate mouse wheel rotations, TestComplete uses the MouseWheel
actions. However, TestComplete records user actions over windows and controls as operations with objects. According to this concept mouse wheel actions may be recorded in another form. For instance, if you rotate the mouse wheel to scroll the contents displayed in a text editor, TestComplete will record the scrolling as assignments to the VScroll.Pos
property of the editor’s window (the VScroll property of the window object provides scripting interface to the vertical scroll bar and the Pos property of the VScroll object specifies the scroll bar’s position).
The MouseWheel
action is used in those cases where TestComplete determines that the object does not contain a vertical scroll bar. For instance, this action will be used to simulate mouse wheel rotations, which you perform within an UpDown control to select a value. Another example of using the MouseWheel
action is when you rotate the mouse wheel to scroll through combo box items without opening the drop-down list of this combo box.
Simulating From Keyword Tests
You can simulate mouse wheel rotations from a keyword test by using the On-Screen Action operation with specified parameters. You can also create a sequence of simulated events by adding the desired number of the On-Screen Action operations to the test.
For instance, to scroll the text in the Notepad window, modify your keyword test as follows:
-
Open your keyword test for editing.
-
Add the On-Screen Action operation to the test. After the operation is dragged, TestComplete will display the Operation Parameters wizard.
-
Then you can specify an object to simulate a click within it in one of the following ways:
-
Type the full name of the object in the first page of the wizard. In our case, It will be a string
Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1)
. -
Click the Pick Object... button, and when the Pick Object dialog appears, drag the target glyph () to the desired object. In our case, if we drag the glyph to the Notepad window and then release the mouse button, the following object will be selected by the wizard: “
Sys.Process("notepad").Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1)
”.
-
-
Click Next.
-
In the second page of the wizard, select the appropriate method from the list. In our case, it will be the
MouseWheel
method. Click Next. -
On the third page of the Operation Parameters wizard you can specify parameters of the selected method:
-
Delta
-
Choose the Constant from the Mode drop-down list.
-
Specify Integer in the Type cell.
-
Specify the rotation “distance”, in wheel detents. In our case, this value is equal to -1, which means that the mouse wheel will be rotated one detent toward the user.
Press ENTER to confirm input in the cell.
-
-
Shift
-
Choose the Code Expression from the Mode drop-down list.
-
Specify Code Expression in the Type cell.
-
Enter the constant, that specifies whether the SHIFT, CTRL or ALT key is pressed during the wheel rotation. For instance, if you enter the
skAlt
constant, the ALT key will be pressed during the rotation. For information about possible values, see TShiftKey. In our case, this parameter is equal toskNoShift
.Press ENTER to confirm input in the cell.
-
-
-
Click Finish to save the changes and to close the wizard. TestComplete will append the operation to the test.
Now the mouse event will be simulated when you run your keyword test. In our example, the mouse will rotate within the Notepad window and Shift will not be pressed during the click.
You can also use the Call Object Method operation to simulate mouse wheel rotations. For more information on how to perform typical tasks in keyword tests, see Common Tasks for Keyword Test Operations.
Simulating From Scripts
To simulate mouse wheel rotation from a script routine, call the OnScreenObject.MouseWheel
method with proper parameters. You can also record a script with necessary mouse wheel events and run the script, when it is needed to reproduce recorded actions.
Another way to simulate rotations of a mouse wheel is to use the MouseWheel
method of the LLPlayer
object. For more information, see the method description.
Simulating From Low-Level Procedures
To record and simulate mouse wheel events you can also use low-level procedures. They register all mouse wheel events that occur during the procedure recording. You can play back the recorded procedure at any time from a script or as a test item of a project. For more information, see Executing Low-Level Procedures.
To view recorded events of a low-level procedure, double-click the desired procedures in the Project Explorer panel. TestComplete will display the contents of the selected procedure in the low-level procedure editor of the Workspace panel. Here you can not only view parameters of the desired mouse wheel operations, but also change these parameters. For example, you can modify the value that specifies how long the wheel rotated.
See Also
Simulating User Actions
Simulating Mouse Actions
Creating and Recording Low-Level Procedures