Sometimes there is a need for having some steps in your script which are out of the control of testcomplete recording feature and your scripting ability. TestComplete provide a feature so-called low-level procedure, when the actions are not determined by the interaction of the script with controls applications, and simple actions. For example consider steps below

  1. hold down the left mouse button,
  2. move the mouse pointer up a few pixels,
  3. release the left mouse button, press it again,
  4. drag pointer a few pixels to the left,
  5. Release the mouse button.

Such actions are usually necessary in graphics applications (eg, MS Paint), where neobhodimoprotestirovat drawing different shapes.
In TestComplete for such action exists to LLPlayer. To gain access to low-level routines, you must first add the item to the project Low Level Procedures Collection.

To do this, right-click on the project name, select Add – New Item and in the dialog box,

 

Select Low-Level Procedures Collection.

Now while writing the script, you can click Start Recording a Low-Level Procedure and TestComplete will record a low-level procedure.

 

Once recording is stopped, the project will be recorded by a low-level procedure, which can be found in the project topic LLCollection1 .  below is sample recorded steps.

Double click on any line opens a dialog box for editing actions. For example, the recorded delay (Column Delay) are usually not necessary and can be set to zero.

You will also notice a new sub gets created in your scripting unit with a call to the low level procedure just created.

LLCollection1.LLP1.Execute ()

Note that TestComplete can use the recorded coordinates relative to the screen or relative to a particular window. In this case we used Screen Related coordinates, i.e. the displacement of the mouse is measured from the upper left corner of the screen.

To run the same procedure with respect to a particular window, the window is enough to pass as a parameter to the method Execute:

wnd = Sys.Process ("mspaint"). Window ("MSPaintApp", "untitled - Paint ", 1)  
LLCollection1.LLP1.Execute (wnd)

If you do not record test scripts using tools recording TestComplete, and write them manually, you can use the object LLPlayer to perform low-level procedures. Sometimes there are situations when the usual methods (Click, Drag, etc.) for some reason does not work in the application under test, then you must use the object LLPlayer.

The LLPlayer object simulates pressing and releasing of mouse buttons, rotations of mouse wheels and pressing and releasing of keyboard keys from your scripts.

Methods of Llplayer

KeyDown Simulates pressing of a key.
KeyUp Simulates releasing of a key.
MouseDown Simulates pressing of a mouse button.
MouseMove Simulates movement of the mouse cursor.
MouseUp Simulates releasing of a mouse button.
MouseWheel Simulates rotating of the mouse wheel.
See also  TestComplete Tutorial - A Complete Guide for Beginners

An example to use Llplayer object (from smartbear help)

Sub LLPMouseMoveExample()

  ' Specifies the coordinates of the first click
  coorX = 15
  coorY = 120

  ' Specifies a delay in milliseconds
  sDelay = 2000 ' 2 seconds

  ' Simulates pressing and releasing the left mouse button
  Call LLPlayer.MouseDown(MK_LBUTTON, coorX, coorY, sDelay)
  Call LLPlayer.MouseUp(MK_LBUTTON, coorX, coorY, sDelay)

  ' Simulates pressing the Shift key
  Call LLPlayer.KeyDown(VK_SHIFT, sDelay) 

  ' Specifies the coordinates of the destination point
  destX = 98
  destY = 275

  ' Simulates mouse movement
  Call LLPlayer.MouseMove(destX, destY, sDelay)

  ' Simulates pressing and releasing the left mouse button
  Call LLPlayer.MouseDown(MK_LBUTTON, destX, destY, sDelay)
  Call LLPlayer.MouseUp(MK_LBUTTON, destX, destY, sDelay) 

  ' Simulates releasing the Shift key
  Call LLPlayer.KeyUp(VK_SHIFT, sDelay) 

End Sub

Let us know if you have any experience using Low-Level Procedure in your projects or if you facing any difficulties using it via comments below.

Subscribe now to receive such information directly into your inbox.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.