| Cogitek RIATest 4 Documentation | Copyright © Cogitek Inc. |
Prerequisites: to enable automation of Windows GUI components make sure that:
RIATest does not record interaction with system UI components of Windows Open/Save dialogs which appear during download/upload operations. However it is possible to automate this part of your tests by writting simple a script.
The technique is as follows. The script will locate the "Start Download" button that we want to be clicked to initiate the download process. We need to emulate a system mouse click on this button to ensure Save dialog appears. Then the file name to save to will be typed in and the Save button will be clicked.
//
// This example will work on Windows only.
//
// The button to click
var btn = FlexButton("Start Download");
// Generate temporary file name to download to
var tempDir = getEnv("TEMP");
var tempFileName = tempDir+"\\downloadfile.html";
trace("Downloading to "+tempFileName);
// Do a system click on component that will start download.
btn=>clickAt(btn=>width/2,btn=>height/2);
var selectFileWindow = SysPane("Desktop")->SysWindow(/./)->SysWindow(/Select location for download/);
// Enter file name
selectFileWindow->SysComboBox("File name:")->SysEdit("File name:")=>SetValue(tempFileName);
// Click Save
selectFileWindow->SysButton("Save")=>Invoke();
// Wait for overwrite dialog to appear
pause(1000);
// If overwrite message appears click Yes
if (isPresent(selectFileWindow->SysWindow(/Confirm/)))
selectFileWindow->SysWindow(/Confirm/)->SysButton("Yes")=>Invoke();
This script should work correctly for Internet Explorer and Mozilla Firefox browsers. You can use a similar technique to automate the file Upload process.
Note: RIATest uses Windows UI Automation API 3.0 that is built-in Windows 7. For earlier Windows versions you need to download and install UI Automation API 3.0 from Microsoft.