Setting the Browser when Running Automated Tests

This functionality is supported only if you are using the Open Agent.

This topic describes how you can set the browser when executing automated tests from a command-line interface, for example from a CI server or from Silk Central. For information on how to set the browser for test replay from the UI, see Changing the Browser Type When Replaying Tests.

  1. Record the test case.
  2. Use the sBrowserType property to specify the browser.
    The following browsers are supported for the Open Agent:
    [ ] const BROWSER_TYPE_INTERNET_EXPLORER   = "InternetExplorer"
    [ ] const BROWSER_TYPE_FIREFOX             = "Firefox"
    [ ] const BROWSER_TYPE_CHROME              = "GoogleChrome"
    [ ] const BROWSER_TYPE_ANDROID_BROWSER     = "AndroidBrowser"
    [ ] const BROWSER_TYPE_SAFARI              = "Safari"
    [ ] const BROWSER_TYPE_EDGE                = "Edge"
    Tip: For a complete list of the available browser types, see the file 4Test.inc file in the Silk Test installation directory, which is by default C:\Program Files (x86)\Silk\SilkTest.
  3. Call the default base state.
  4. Replay the test case.

Examples

The following code shows a sample frame file for the sample web application http://demo.borland.com/InsuranceWebExtJS/:
[-] window BrowserApplication WebBrowser
 [ ] locator "//BrowserApplication"
 [ ] 
 [ ] // The start URL
 [ ] const sUrl = "http://demo.borland.com"
 [ ] 
 [ ] STRING sBrowserType = NULL
 [ ] STRING sConnectionString = NULL
 [ ] STRING sCmdLine = NULL
 [ ] 
 [ ] const bCloseOtherTabs = TRUE
To run a test against a specific browser, set the sBrowserType property and call the base state. The following code sample implements a simple test case that opens the application under test in Internet Explorer:
[-] testcase OpenGMOAjaxAppIE () appstate none
 [ ] WebBrowser.sBrowserType = BROWSER_TYPE_INTERNET_EXPLORER 
 [ ] WebBrowser.sCmdLine = "C:\\Program Files\\Internet Explorer\\iexplore.exe" // Optional
 [ ] DefaultBaseState()
 [ ] WebBrowser.BrowserWindow.DemoApplication.Select()
The following code sample opens the same application in Mozilla Firefox:
[-] testcase OpenGMOAjaxAppFF () appstate none
 [ ] WebBrowser.sBrowserType = BROWSER_TYPE_FIREFOX
 [ ] DefaultBaseState()
 [ ] WebBrowser.BrowserWindow.DemoApplication.Select()
To run the test against a remote browser, for example Apple Safari on a Mac, you have to additionally specify the connection string:
[-] testcase OpenGMOAjaxAppSafari () appstate none
 [-] recording
  [ ] WebBrowser.sBrowserType = BROWSER_TYPE_SAFARI
  [ ] WebBrowser.sConnectionString = "host=10.0.0.1"
  [ ] DefaultBaseState()
  [ ] WebBrowser.BrowserWindow.DemoApplication.Select()