Recording Tips

When recording a terminal services script, you must be aware that unplanned events can change the position and size of target windows during replay, causing test runs to fail. Here are some general tips that will help you avoid the effort of finding and fixing such replay errors.

Try launching the application via the Windows Run command. Launching the application via a desktop icon or mouse click may also work, but consider if you will be moving the application to a different server, or if the GUI will vary between users, in which case a desktop icon might appear in a different location. It is therefore recommended that you type the path to the application’s EXE file in the Windows Run command window.

Keyboard Shortcuts

Mouse clicks require x/y coordinates, a window reference, and the target window must have focus. While GUI testing technologies for tracking mouse clicks have become increasingly reliable, Windows remains a dynamically changing environment, so you must build scripts that can tolerate minor inconsistencies. One way to do this is to use keyboard shortcuts. For shortcuts, the only requirement is window focus.

Note: The Windows Logo key is not supported, as it moves the focus away from the Citrix Recorder.

Almost all menu systems in Windows applications have Alt key combinations that can be used to initiate specific menu commands. To record use of an Alt key shortcut, first give your application focus, then press the Alt key, this gives the menu system focus. Notice that many of the menu items have one of their letters underlined. This indicates which Alt key commands are available for specific menu items. Press appropriate letter keys to gain access to sub-menus until you reach the menu item that you want to initiate. In some cases, a menu item itself will have a key combination. For example, to open a document in Microsoft Word use the Ctrl+O combination. This shortcut does not require that the menu have focus.

Maximizing Windows

If keyboard shortcuts are not available and you must use the mouse, you can reduce the chance of triggering inaccurate mouse clicks by maximizing the window that you are working with. This places the window in a fixed position each time it is used and, in turn, makes mouse clicks more accurate. As a general rule, if a window allows for maximization, it is recommended that you take advantage of it.

Note: Alt-Space, X is the Windows keyboard combination for maximizing an active window

When a window does not allow for maximization, during the recording session, move the window to the upper left-hand corner of the desktop before clicking. When recording, the recorder may not be able to pick up on the window handle that you have in the foreground, so having the coordinates relative to the desktop is a must.

Keeping the System Clean

To eliminate unexpected events during terminal services sessions, ensure that you keep your Windows desktop as uncluttered as possible. Imagine, for example, that while your script is replaying, a Windows network message appears. Your script will break because the subsequent mouse click will go to the Windows network message window instead of your intended application window.

Ensure Correct Focus

Before clicking a window, ensure that the window you intend to click exists and has focus. Here is a sample BDL function that helps automate this process:

function MyCitrixWaitForWindowCreationAndActivation(sCaption:string; 
				nMatch    : number optional;
				nStyle    : number optional;
				nX        : number optional;
				nY        : number optional;
				nWidth    : number optional;
				nHeight   : number optional
				) : number
var 
    hwndNewWindow  : number;  // hwnd of the new window created
    nRTT:number; 
begin
	//
	// Check if window exists
	//
		hwndNewWindow := CitrixSearchWindow(sCaption, nMatch);
  		hwndNewWindow := 0;
	//
	// If window doesn’t exist, wait for creation
	//   
		if (hwndNewWindow < 1) then
			hwndNewWindow := CitrixWaitForWindowCreation(sCaption, nMatch,
			nStyle, nX, nY, nWidth, nHeight);
		end;
	// 
	// Check if window is already active, wait if it’s not active 
	// 
		MyCitrixWaitForWindowActivate(hwndNewWindow);     
		MyCitrixWaitForWindowCreationAndActivation:=hwndNewWindow;
		
end MyCitrixWaitForWindowCreationAndActivation;

Using Parameters

If you input the same information more than once, the system under test caches the data in memory rather than repeating the same work. For this reason it is important that you vary input/request data so that the work is as realistic as possible. For example, use different user accounts that have different data ranges. This can be accomplished using a CSV (comma separated values) file as input for a test.

Adding Verifications

Verifications are checks that are added to code to check if the responses that are received from the server are correct. When performing GUI based testing, verifications are automatically added to your script via window synchronizations, however it is recommended that you add additional verifications to your code.

Adding Timers

Custom timers are critically important for tracking an application’s response times. Without custom timers, you cannot determine your end user’s overall experience with an application. Metrics can help determine which aspects of your application are performing well and which are not.

Before you begin adding custom timers to your test script, identify the critical areas of your application and determine where your MeasureStart and MeasureStop calls should be placed. For this effort it is good practice to review the log in TrueLog Explorer.

Here is an example of using timers in a Silk Performer script:

// 
// Submit a work order. 
// 
CitrixMouseClick(27, 31, hwndWorkOrder, MOUSE_ButtonLeft);     

// 
// Start the response time clock. 
// 
MeasureStart("202.01: Work Order Submission.");

// 
// Wait for the "Order Submission Complete" dialog box. 
// 
MyCitrixWaitForWindowCreationAndActivation(
	"Order Submission Complete",
	MATCH_Exact
	);   

// 
// Stop the response time clock. 
// 
MeasureStop("202.01: Work Order Submission ");