Windows Desktop Automation
abstract This section details how to test Windows Desktop Applications. If you are not familiar with Sahi Pro, see Quick Tutorial on Sahi Pro
- Start Sahi Dashboard
Start SahiWin exelink on Sahi dashbord. "Sahi windows agent started!" message appears on Sahi Pro console.
- To Launch Sahi Controller, click the Desktop icon on the Sahi Dashboard.
- On the Controller, go to the Record tab and check "enable recording/identification for Windows" checkbox. The Controller can be used to interact with the desktop application. User can Identify, Click, Set, Assert, choose Other Actions, or user can even Test an expression from Evaluate Expression to perform an action on the Windows Desktop application.
infoMake sure popup blockers are turned off.
- Launch the Controller and check "enable recording/identification for Windows" checkbox.
- To identify an element, press the CTRL key, hover over any element and release the CTRL key.
infoThe accessors will not be populated till CTRL key is released. This is an optimization to stop Sahi from unwanted processing.
Accessor:shows the Sahi accessor for that element
Alternatives:shows all alternative accessors for that element
Value:shows the value of the current element. Mostly this is the input text or the visible text.
Mode:shows the Automation mode
Prefixmeans element is present on the taskbar.
Start SahiWin exemust be clicked from Sahi Dashboard and ' Windows ' checkbox at right side top most corner in controller must be checked during identification or recording.
- If during identification, Sahi is identifing background elements, then goto display setting of PC and change
Change the size of text, apps and other itemsto 100% (Recommended).
- For SilverLight, XBAP (i.e browser based desktop application) during identification, if Sahi is not identifing some boundary elements, then maximize the browser.
- Refer Identify Elements for a better understanding.
- Put a valid Sahi expression in the Evaluate Expression box
- Select mode as 'Sahi-Windows'
- Click on
→. The result will be seen in the bottom box.
AppendWhile recording, selecting and clicking on
Appendwill append the steps to the currently recording script. This is mainly used for manually append any step from Evaluate Expression to the currently recording script.
HighlightCan be used on selected text to highlight the element (shows a red 1 pixel border briefly). Invokes the
Drop downLists some actions like Click, Get Value, Get Text etc.
infoNote: Selecting some text and pressing '→' will only evaluate the selected text.
Start SahiWin exemust be clicked on Sahi Dashboard and 'Sahi-Windows' must be selected as the 'Select mode for evaluate' during evaluating
infoRefer Evaluate Expression for a better understanding.
- To record a script, launch the Controller, check 'Windows' checkbox at right side top most corner in controller, give a script name and click 'Record'. Actions done on the Windows Desktop are recorded automatically.
- Steps can also be recorded from the Controller.
A. You can use Click, Set, Assert, choose 'Other Actions' to perform an action on the Windows Desktop Application.
B. You will need to record these steps explicitly by clicking on 'Append'.
Start SahiWin exemust be clicked from Sahi Dashboard and 'Windows' checkbox must be checked in Sahi Controller during identification or recording.
- Cursor Feedback:During recording, mouse cursor turns to Arrow with Red dot until the step is recorded.
- Refer Record a script for a better understanding.
- Choose the script.
- Select Start Mode as
- You can leave the Start url blank. This is not used for Windows Desktop Application.
- Click on Play to playback the script.
- Click on Logs to view the logs of the played back script.
infoNote: A script cannot be played back if
Start SahiWin exeis not clicked on Sahi Dashboard.
infoRefer Playback Tab for a better understanding.
- Choose the script/suite/scenario from the Editor and click on the Playback button.
- Choose the Start Mode as Windows.
- Choose either of the two options - 'Run in single machine' or 'distributed (multiple machines)'.
- Press Run to playback the test.
infoNote: A script cannot be play back if
Start SahiWin exeis not clicked on Sahi Dashboard.
To start a Windows application from script, use
_execute("correct/path/your_application.exe"); // or _execute("correct/path/your_application.bat");
- All code interactions with Windows will need to be preceded by _setMode("WINDOWS")
- In some cases, the element can be found only on vertical scroll. In such a case, user must specify a scrollable parent element using
_startLookInsideapi. Windows Automation will gradually scroll vertically inside this scrollable parent element and try to find the element.
- It is possible, that the element exists but is visible only on scrolling horizontally. In such a case, Windows Automation will automatically scroll horizontally starting from left to right and make the element visible.
// For example element for folder '823' can be found only on vertical scroll. So if we try to perform any action on this element, it will fail. // In such case we use _startLookInside api and thus the element will be found on vertical scroll. _startLookInside(_list("Items View")); // Specify a scrollable parent element // Now if _listitem("823") is not found, //Windows automation will scroll vertically from top to bottom inside _list("Items View") and try to find the element. _click(_listitem("823")); _stopLookInside();