Simulating Mouse Wheel Rotation

Applies to TestComplete 15.45, last modified on December 01, 2022

In TestComplete tests, you can simulate mouse and mouse wheel events. You can do it in keyword tests, scripts, and low-level procedures. This topic describes how to simulate a mouse wheel rotation in your tests. For information on how to simulate other mouse events, see Simulating Mouse Actions.

About

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. For example, TestComplete uses this action to simulate mouse wheel rotation to select a value in an up-down control or to scroll through combo box items without opening the drop-down list of this combo box.

Note: TestComplete does not record mouse wheel actions over web pages.

Simulating From Keyword Tests

You can simulate mouse wheel rotations from a keyword test by using the On-Screen Action operation.

For example, to add a scroll action to a test:

  1. Open your keyword test for editing.

  2. Add the On-Screen Action operation to the test. TestComplete will show the Operation Parameters wizard.

  3. Specify an object to simulate user actions over it in one of the following ways:

    • Type the full name of the object.

    • Click Pick Object, and when the Pick Object dialog appears, drag the target glyph () to the desired object.

    Click Next.

  4. On the second page of the wizard, select the MouseWheel method from the list. Click Next.

  5. On the third page of the Operation Parameters wizard, specify parameters of the selected method:

    • The Delta parameter specifies the rotation “distance”, in wheel detents. For example, -1 means that the mouse wheel will be rotated one detent toward the user.

    • The Shift parameter specifies whether the SHIFT, CTRL or ALT key is pressed during the wheel rotation. For example, if you enter the skAlt constant, the ALT key will be pressed during the rotation. For information about possible values, see TShiftKey.

  6. 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.

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. For example:

Sys.Process("Notepad").Window("Notepad", "*").Window("Edit", "").MouseWheel(-1);

You can also record a script with necessary mouse wheel events and run the script when it is needed to reproduce the recorded actions.

Note: TestComplete does not record mouse wheel events over web pages. See Recording Specifics.

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 another test or from the project’s execution plan. 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

Highlight search results