Sahi - Multiple modes/application types
From Sahi Pro v7.0.0, it is possible to interact with multiple applications from the same script.
With the Sahi Pro Desktop Add-on, we can interact with Window Desktop applications and Java applications
The _setMode API is used to switch modes within a script.
// by default start with browser interaction
_navigateTo("/demo/training/");
_setValue(_textbox("user"), "test");
...
// Switch to Windows automation
_setMode("WINDOWS");
_selectWindow("/Notepad/");
_mouseOver(_toolBar(""));
_click(_button("Replace..."));
_click(_tabItem("Find"));
...
// Switch back to browser
_setMode("BROWSER");
_click(_button("Logout"));
Available Modes
Mode | Description | Available in |
---|---|---|
GENERIC | No specific UI application. | Sahi Pro |
BROWSER | Desktop browsers like Chrome, Firefox, Internet Explorer etc. as defined in browser_types.xml. Eg. chrome | Sahi Pro |
WINDOWS | Native Windows applications (WPF, WinForms, .NET, SilverLight, XBAP) | Sahi Pro with Desktop Add-on |
JAVA | Java desktop and Web Start/JNLP applications | Sahi Pro with Desktop Add-on |
JAVA_APPLET | Java Applets | Sahi Pro with Desktop Add-on |
Playback Start Mode
The Playback Start Mode, specified before a script or suite is executed, is the mode with which scripts will start playing.The mode can be later changed using _setMode.
Sahi Pro by default starts all scripts in BROWSER mode and automatically launches a browser at the start.
If a script needs to start by interacting with JAVA applications, the start mode can be set as JAVA. In this case no browser is opened at start.
Notes on Default and Start With options
-
When "Desktop Browser" is chosen as the Start Mode option, a browser of the Default Desktop Browser type is started automatically at the start of the script.
This browser session is automatically selected, so that the first step in the script is addressed to this browser instance.
-
When "Generic" or "Windows" is chosen as the Start Mode option, no browser launch is made.
If you want to interact with the browser, the script has to explicitly do
before steps on browser can be executed._setMode("BROWSER"); var $instanceId = _launchNewBrowser(); _selectBrowser($instanceId);
If browserType is not specified in _launchNewBrowser, a new browser of the
default browser type (as specified at playback time from editor or batch file or ant) is launched.
warning The ant target usesstartWith
parameter to specify start mode. The values of startWith are:
Visible Text startWith value Desktop Browser desktopbrowser Generic none Windows windows