Sahi - Windows Desktop Automation
abstract
This section details how to test Windows Desktop Applications.
If you are not familiar with Sahi Pro, please see Quick Tutorial on Sahi Pro
If you are not familiar with Sahi Pro, please see Quick Tutorial on Sahi Pro
Installation
DownloadSahi Pro
and Sahi Pro Desktop Add-on
from Downloads Archive.Install
Sahi Pro
into a folder without spaces in its path.Then install
Sahi Pro Desktop Add-on
into the same folder as Sahi Pro
.License
Sahi Pro Desktop Add-on needs a separate license from Sahi Pro.Register here for a 30 day fully functional trial version.
Start Windows Desktop Automation
- Start Sahi Dashboard
- Click
Start SahiWin exe
link on Sahi dashbord.
After clickingStart SahiWin exe
"Sahi windows agent started!" message appears on Sahi Pro console.
Using the Controller
Start Sahi controller by following methods- Open up the browser of your choice by clicking on any of the browser icons from Sahi Dashboard.
- Press ALT and double click on the browser window. Sahi's Controller window will pop up.
- On the Controller, go the the Record tab and check "enable recording/identification for Windows" checkbox.
infoIf that does not work, press CTRL and ALT keys together and then double click. Make sure popup blockers are turned off. For further trouble shooting have a look at this help link.
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.
infoFor better understanding please refer Sahi Controller and Java Controller.
Element Identification
- 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.
Accessor:
shows the Sahi accessor for that elementAlternatives:
shows all alternative accessors for that elementValue:
shows the value of the current element. Mostly this is the input text or the visible text.Prefix:
window name.Mode:
shows the Automation mode
infoBlank
Prefix
means element is present on the taskbar.infoNote:
Start SahiWin exe
must be clicked from Sahi Dashboard and 'Windows' checkbox at right side top most corner in controller must be checked during identification or recording.infoFor better understanding please refer Identify Elements.
Evaluate Expression
Evaluating Windows Desktop Application expression through Controller. It helps while identifying elements or while debugging.- 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. Append
While recording, selecting and clicking onAppend
will 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.Highlight
Can be used on selected text to highlight the element (shows a red 1 pixel border briefly). Invokes the_highlight
API.Drop down
Lists some actions like Click, Get Value, Get Text etc.
infoNote: Selecting some text and pressing '→' will only evaluate the selected text.
infoNote:
Start SahiWin exe
must be clicked on Sahi Dashboard and 'Sahi-Windows' must be selected as the 'Select mode for evaluate' during evaluatinginfoFor better understanding please refer Evaluate Expression.
Recording a script
This is similar to recording a Sahi script for normal browser testing.-
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'.
infoNote:
Start SahiWin exe
must be clicked from Sahi Dashboard and 'Windows' checkbox must be checked in Sahi Controller during identification or recording.infoFor better understanding please refer Record a script.
Playback
From Controller
Once a script is recorded, it can be played back from the Controller Playback tab itself.- Choose the script.
- Select Start Mode as
Windows
. - 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
Generic mode is used to run a script when _setMode already defined in the script.
Start SahiWin exe
is not clicked on Sahi Dashboard.Generic mode is used to run a script when _setMode already defined in the script.
infoFor better understanding please refer Playback Tab.
From the Editor
You can playback the script from the Editor as well.- Choose the script/suite/scenario from the Editor and click on the Playback button.
- Choose any Browser.
- Choose the Start Mode as Windows.
- Choose any Start URL.
- Choose the Run 'sequentially single browser session' or 'distributed (multiple machines)' option.
- Press Run to playback the test.
infoNote: For distributed run choose Threads as 1 for suite / scenario file.
Do not leave this as 5.
Do not leave this as 5.
infoNote: A script cannot be play back if
Start SahiWin exe
is not clicked on Sahi Dashboard.Via command line
- Click on Dashboard -> Bin
- For drun, run the command in following format:
drun.bat [scriptName] [startURL] ["BROWSER,DEVICE_ID|default;START_MODE"] [tags]
- To run a script:
drun.bat script_name.sah http://sahitest.com/demo/ "chrome;Windows"
- To run a suite or scenario file:
drun.bat suite_name.dd.csv http://sahitest.com/demo/ "chrome;Windows" "all"
-
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")
-
For executing Windows application only scripts, use "generic" as Start Mode, and use _setMode("WINDOWS") at the start of script.
infoNote: A script cannot be play back if
Start SahiWin exe
is not clicked on Sahi Dashboard.infoFor better understanding please refer Playback on Desktop.