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 Add-on, we can interact with Window Desktop applications and Java applicationsThe _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 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 Add-on |
JAVA | Java desktop and Web Start/JNLP applications | Sahi Pro Desktop Add-on |
JAVA_APPLET | Java Applets | Sahi Pro Desktop Add-on |
ANDROID | Android applications (native and hybrid) | Sahi Pro Mobile Add-on |
IOS | iOS applications (native, hybrid and web) | Sahi Pro Mobile Add-on |
SAP | SAP GUI Application | Sahi Pro SAP 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. 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
- 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
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 Browser BROWSER Generic GENERIC Windows WINDOWS Java JAVA Android ANDROID Android Browser ANDROID_BROWSER iOS IOS iOS Browser IOS_BROWSER SAP SAP