Adding Tests that Use the Open Agent to the DefaultBaseState

If you want the recovery system to perform additional steps after it restores the default base state, record a new test case based on no application state and paste it into the declaration of the main window of your application.

  1. Open your test application and the frame file of the test application.
  2. Click Record > Testcase. Silk Test Classic displays the Record Testcase dialog box.
  3. From the Application state list box, select (None).
  4. Click Start Recording. Silk Test Classic opens the Recording window, which indicates that you can begin recording.
  5. When you have finished recording the actions that you want to perform whenever the base state is restored, click Stop on the Recording window. Silk Test Classic displays the Record Testcase dialog box.
  6. Click Paste to Editor.
  7. In the Update Files dialog box, select Paste testcase and update window declarations(s).
  8. Click OK. Silk Test Classic creates a new script file with the new test case.
  9. Add a new method named BaseState to the declaration of the main window in the test frame file.
  10. Paste the recorded actions from the script file into the new BaseState method.
  11. Choose File > Save to save the test frame file.

Examples

For example, if you want the Insurance Company web application to preselect Auto Quote each time the base state is restored, the new declaration for the main window in the frame file should look similar to the following:
window BrowserApplication WebBrowser
  locator "//BrowserApplication"

  // Go to Options -> Application Configurations... to switch the browser
  // Alternatively set sDir and sCmdLine if you want to start a custom browser

  // The working directory of the application when it is invoked
  // const sDir = "."

  // The command line used to invoke the application
  // const sCmdLine = ""

  // The start URL
  const sUrl = "http://demo.borland.com/InsuranceWebExtJS/index.jsf"

  const bCloseOtherTabs = TRUE

  // The list of windows the recovery system is to leave open
  // const lwLeaveOpenWindows = {?}
  // const lsLeaveOpenLocators = {?}
  BrowserWindow BrowserWindow
    locator "//BrowserWindow"
    DomListBox QuickLinkJumpMenu
      locator "SELECT[@id='quick-link:jump-menu']"
  // ...

  // Recorded actions, which should be performed whenever the base state of the application is restored
  Basestate()
    WebBrowser.BrowserWindow.QuickLinkJumpMenu.Select("Auto Quote")
To execute the same web application on Apple Safari on an iOS device each time the base state is restored, the new declaration for the main window in the frame file should look similar to the following:
window BrowserApplication WebBrowser
  locator "//BrowserApplication"

  // Go to Options -> Application Configurations... to switch the browser
  // Alternatively set sDir and sCmdLine if you want to start a custom browser

  // The working directory of the application when it is invoked
  // const sDir = "."

  // The command line used to invoke the application
  // const sCmdLine = ""

  // The start URL
  const sUrl = "http://demo.borland.com/InsuranceWebExtJS/index.jsf"

  const bCloseOtherTabs = TRUE

  // Overrides the browser type of the application configuration
  STRING sBrowserType = BROWSER_TYPE_SAFARI

  // Overrides the connection string of the application configuration
  STRING sConnectionString = "host=macmini1702.microfocus.com"

  // The list of windows the recovery system is to leave open
  // const lwLeaveOpenWindows = {?}
  // const lsLeaveOpenLocators = {?}
  BrowserWindow BrowserWindow
    locator "//BrowserWindow"
    DomListBox QuickLinkJumpMenu
      locator "SELECT[@id='quick-link:jump-menu']"
  // ...

  // Recorded actions, which should be performed whenever the base state of the application is restored
  Basestate()
    WebBrowser.BrowserWindow.QuickLinkJumpMenu.Select("Auto Quote")
To execute the native mobile application InsuranceMobile.apk on an Android device each time the base state is restored, the new declaration for the main window in the frame file should look similar to the following:
[-] window MobileDevice Device
	[ ] locator "/MobileDevice"
	[ ] 
	[ ] // Go to Options -> Application Configurations... to switch the mobile device
	[ ] // Alternatively set sConnectionString
	[ ] 
	[ ] // Overrides the connection string of the application configuration
	[ ] STRING sConnectionString = "deviceName=MotoG3;platformName=Android;app=C:\\Temp\InsuranceMobile.apk"
	[ ] 
	[ ] // The list of windows the recovery system is to leave open
	[-] MobileTextField Email
		[ ] locator "@resource-id='silktest.insurancemobile:id/email'"