Multiple Modes in a Single Script
From Sahi Pro v7.0.0, it is possible to interact with multiple applications from the same script. With the Sahi Pro Desktop Engine, we can interact with Window Desktop applications and Java applications
The _setMode function 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
Section titled “Available Modes”| Mode | Description | Available in |
|---|---|---|
| GENERIC | No specific technology. | All |
| BROWSER | Desktop browsers like Chrome, Firefox, Internet Explorer etc. as defined in browser_types.xml. Eg. chrome |
Sahi Pro |
| ANDROID_BROWSER | Android web applications | Sahi Pro |
| IOS_BROWSER | iOS web applications | Sahi Pro |
| WINDOWS | Native Windows applications (WPF, WinForms, .NET, SilverLight, XBAP) | Sahi Pro Desktop Engine |
| JAVA | Java desktop and Web Start/JNLP applications | Sahi Pro Desktop Engine |
| JAVA_APPLET | Java Applets | Sahi Pro Desktop Engine |
| ANDROID | Android applications (native and hybrid) | Sahi Pro Mobile Engine |
| IOS | iOS applications (native, hybrid and web) | Sahi Pro Mobile Engine |
| SAP | SAP GUI Application | Sahi Pro SAP Engine |
Start Mode
Section titled “Start Mode”The 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. If Sahi Browser capability is enabled, 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
Section titled “Notes on Default and Start With options”-
When “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” or “Java” 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
_setMode("BROWSER");var $instanceId = _launchNewBrowser();_selectBrowser($instanceId);before steps on browser can be executed.
If browserType is not specified in _launchNewBrowser, a new browser of the default browser type (as specified at run time from editor or batch file or ant) is launched.

