cancel
Showing results for 
Search instead for 
Did you mean: 

My low level click shared to all

Highlighted
Community Leader

My low level click shared to all

I share with the community my low level click. Used widely in our web/desktop tests.

 

Note:

  system.debug is a global unit setting activating more logs when set to true.

  system.logDebug is a global log attributes setting.

 

/**
 * Click dans un objet via les méthodes Low Level<br>
 * @author Biache Benoit  
* @memberof system
* @function * @param {Object} Obj - Objet à cliquer, s'il n'est pas existant alors ignore le click, pour cliquer directement dans l'écran utiliser <b>"screen"</b> * @param {number} [X=-1] - Position X du click depuis le bord gauche de l'objet, s'il est non défini ou défini à <b>-1</b> alors prend le milieu * @param {number} [Y=-1] - Position Y du click depuis le bord haut de l'objet, s'il est non défini ou défini à <b>-1</b> alors prend le milieu * @param {number} [Button=MK_LBUTTON] - Bouton utilisé pour le click (MK_LBUTTON, MK_RBUTTON_ MK_MBUTTON) * @param {number} [Repeat=1] - Nombre de click à jouer. S'il n'est pas défini alors n'effectue qu'un clic * @param {number} [Wait=200] - Durée en ms entre chaque clic, utile si <b>Repeat</b> est > 1 * @param {boolean} [Hide=true] - <b>true</b> alors gérer le masquage de l'objet Indicator */ function clickInObject(Obj, X = -1, Y = -1, Button = MK_LBUTTON, Repeat = 1, Wait = 200, Hide = true) { if ((Obj == undefined) || (Obj == null))
if (system.debug)
Log.Message("clickInObject() - Objet inexistant", "", pmLowest, system.logDebug);
return;
} if (Obj == "screen") { X = X == -1 ? Sys.Dekstop.Width >> 1 : X; Y = Y == -1 ? Sys.Dekstop.Height >> 1 : Y; Xr = X; Yr = Y; if (system.debug) Log.Message("clickInObject(screen, " + X + ", " + Y + ", " + Button + ", " + Repeat + ", " + Wait + ", " + Hide + ") - Click Low Level", "", pmLowest, system.logDebug); } else { if ((Obj != null) && (!Obj.Exists)) { if (system.debug)
Log.Message("clickInObject() - Objet invalide", "", pmLowest, system.logDebug);
return;
} X = X == -1 ? Obj.Width >> 1 : X; Y = Y == -1 ? Obj.Height >> 1 : Y; Xr = Obj.ScreenLeft + X; Yr = Obj.ScreenTop + Y; if (system.debug) Log.Message("clickInObject(" + Obj.FullName + ", " + X + ", " + Y + ", " + Button + ", " + Repeat + ", " + Wait + ", " + Hide + ") - Click Low Level", "X reel = " + Xr + ", Y reel = " + Yr, pmLowest, system.logDebug); } if ((Hide) && ((Yr < 350) && (Xr > (Sys.Desktop.Width - 400)))) Indicator.Hide(); for (let loop = 0; loop < Repeat; loop++) { LLPlayer.MouseDown(Button, Xr, Yr, 100); LLPlayer.MouseUp(Button, Xr, Yr, 50); aqUtils.Delay(Wait); } if (Hide) Indicator.Show(); }

 

 

Usage is very simple :

 

let item = my object;

// Left simple click in the middle of the object
clickInObject(item);

// Right simple click at pos 10,10 inside the object
clickInObject(item, 10, 10, MK_RBUTTON);

// Double left click on hte middle of the object:
clickInObject(item, -1, -1, MK_LBUTTON, 2, 25);

// Left click on middle of the screen
clickInObject("screen");

 

 

Un sourire et ça repart

1 REPLY 1
Highlighted
Community Manager

@BenoitB thank you so much for sharing this great piece of information with the community members!

This is greatly appreciated.


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get properties of a web page element

See replies!

Compare images using the Region Checkpoint

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors