Can SilkTest have a DefaultBaseState that consists of two applications?

Can SilkTest have a DefaultBaseState that consists of two applications?

Yes - here is an example with Notepad & WordPad.

1 - Record a frame file for each application (In this example Notepad & WordPad)

2 - Decide which application will be your starting point and comment out the const statement for the other
application e.g. in this example I choose Notepad as my starting point so I therefore left its const statement intact and commented out the const statement in my WordPad frame file. Although the DefaultBaseState will consist of the two applications it can only have one of them as a starting point. In my example you will also see that both the include files for NotePad and WordPad reference the window MessageBoxClass, this is a generic class for both applications and may be commented out in one of the frame files. When finished altering the frame file compile both.

3 - Create a new 4Test Include file and copy the window declarations from the Notepad include file and the
altered WordPad include file. Next create a list of window and assign the wMainWin identifier for each application e.g. for this example NotePad and WordPad

[ ] list of window lwApps = {..} 
                        [ ] Notepad 
                        [ ] WordPad



4 - Next define a TestCaseEnter ( ) so that wMainWindow variable can be reassigned and the
AppState set for each application in turn e.g.

[ ] TestCaseEnter ( ) 
                        [ ] window wCurrentApp 
                        [ ] for each wCurrentApp in lwApps 
                                [ ] wMainWindow = wCurrentApp 
                                [ ] SetAppState ( )



5 -Then create a TestCaseExit ( ) again so that the wMainWindow variable can be reassigned and the AppState set for each application in turn. In my example the TestCaseExit ( ) there is also code to handle the testcase exiting with and error e.g.

[ ] TestCaseExit (BOOLEAN bException ) 
                        [ ] if bException 
                                [ ] ExceptLog ( ) 
                        [ ] window wCurrentApp 
                        [ ] for each wCurrentApp in lwApps 
                                [ ] wMainWindow = wCurrentApp 
                                [ ] if (wCurrentApp.Exists ( )) 
                                    [ ] SetAppState ( )



6 - When writing/recording a testcase you must always base them on the DefaultBaseState and you must set each application active as you us them.

Below is the code contained in the include file for this example:

[ ] window wMainWindow
[ ] 
[-] list of window lwApps = {...}
    [ ] Notepad
    [ ] WordPad
[ ] 
[-] TestCaseEnter ()
    [ ] window wCurrentApp
    [-] for each wCurrentApp in lwApps
        [ ] wMainWindow = wCurrentApp
        [ ] SetAppState()
        [ ] // Define your own TestCaseExit. 
[-] TestCaseExit (BOOLEAN bException)
    [-] if bException 
        [ ] ExceptLog()
    [ ] window wCurrentApp
    [-] for each wCurrentApp in lwApps
        [ ] wMainWindow = wCurrentApp
        [-] if (wCurrentApp.Exists())
            [ ] SetBaseState()
[ ] 
[ ] 
[-] window MainWin Notepad
    [-] multitag "*Notepad"
        [ ] "$D:\WINNT\system32\notepad.exe"
    [ ] 
    [ ] // The working directory of the application when it is invoked
    [ ] const sDir = "D:\"
    [ ] 
    [ ] // The command line used to invoke the application
    [ ] const sCmdLine = "D:\WINNT\system32\notepad.exe "
    [ ] 
    [ ] // The first window to appear when the application is invoked
    [ ] // const wStartup = ?
    [ ] 
    [ ] // The list of windows the recovery system is to leave open
    [ ] // const lwLeaveOpen = {?}
    [ ] 
    [-] Menu File
        [ ] tag "File"
        [-] MenuItem New
            [-] multitag "New"
                [ ] "$9"
        [-] MenuItem Open
            [-] multitag "Open"
                [ ] "$10"
        [-] MenuItem Save
            [-] multitag "Save"
                [ ] "$1"
        [-] MenuItem SaveAs
            [-] multitag "Save As"
                [ ] "$2"
        [-] MenuItem PageSetup
            [-] multitag "Page Setup"
                [ ] "$32"
        [-] MenuItem Print
            [-] multitag "Print"
                [ ] "$14"
        [-] MenuItem Exit
            [-] multitag "Exit"
                [ ] "$28"
    [-] Menu Edit
        [ ] tag "Edit"
        [-] MenuItem Undo
            [-] multitag "Undo"
                [ ] "$25"
        [-] MenuItem Cut
            [-] multitag "Cut"
                [ ] "$768"
        [-] MenuItem Copy
            [-] multitag "Copy"
                [ ] "$769"
        [-] MenuItem Paste
            [-] multitag "Paste"
                [ ] "$770"
        [-] MenuItem Delete
            [-] multitag "Delete"
                [ ] "$771"
        [-] MenuItem Find
            [-] multitag "Find"
                [ ] "$3"
        [-] MenuItem FindNext
            [-] multitag "Find Next"
                [ ] "$8"
        [-] MenuItem Replace
            [-] multitag "Replace"
                [ ] "$40"
        [-] MenuItem GoTo
            [-] multitag "Go To"
                [ ] "$41"
        [-] MenuItem SelectAll
            [-] multitag "Select All"
                [ ] "$7"
        [-] MenuItem TimeDate
            [-] multitag "Time?Date"
                [ ] "$12"
    [-] Menu Format
        [ ] tag "Format"
        [-] MenuItem WordWrap
            [-] multitag "Word Wrap"
                [ ] "$27"
        [-] MenuItem Font
            [-] multitag "Font"
                [ ] "$37"
    [-] Menu Help
        [ ] tag "Help"
        [-] MenuItem HelpTopics
            [-] multitag "Help Topics"
                [ ] "$5"
        [-] MenuItem AboutNotepad
            [-] multitag "About Notepad"
                [ ] "$11"
    [-] TextField TextField1
        [ ] tag "$15"
[-] window MessageBoxClass MessageBox
    [ ] tag "~ActiveApp/[DialogBox]$MessageBox"
    [-] PushButton OK
        [ ] tag "OK"
    [-] PushButton Cancel
        [ ] tag "Cancel"
    [-] PushButton Yes
        [ ] tag "Yes"
    [-] PushButton No
        [ ] tag "No"
    [-] StaticText Message
        [ ] motif tag "#2"
        [ ] tag "#1"
[ ] 
[ ] //const wMainWindow = WordPad
[ ] 
[-] window MainWin WordPad
    [-] multitag "*WordPad"
        [ ] "$D:\Program Files\Windows NT\Accessories\wordpad.exe"
    [ ] 
    [ ] // The working directory of the application when it is invoked
    [ ] const sDir = "D:\Documents and Settings\Administrator\My Documents"
    [ ] 
    [ ] // The command line used to invoke the application
    [ ] const sCmdLine = "D:\Program Files\Windows NT\Accessories\wordpad.exe "
    [ ] 
    [ ] // The first window to appear when the application is invoked
    [ ] // const wStartup = ?
    [ ] 
    [ ] // The list of windows the recovery system is to leave open
    [ ] // const lwLeaveOpen = {?}
    [ ] 
    [-] Menu File
        [ ] tag "File"
        [-] MenuItem New
            [-] multitag "New"
                [ ] "$57600"
        [-] MenuItem Open
            [-] multitag "Open"
                [ ] "$57601"
        [-] MenuItem Save
            [-] multitag "Save"
                [ ] "$57603"
        [-] MenuItem SaveAs
            [-] multitag "Save As"
                [ ] "$57604"
        [-] MenuItem Print
            [-] multitag "Print"
                [ ] "$57607"
        [-] MenuItem PrintPreview
            [-] multitag "Print Preview"
                [ ] "$57609"
        [-] MenuItem PageSetup
            [-] multitag "Page Setup"
                [ ] "$32771"
        [-] MenuItem N1DError1
            [-] multitag "1 D:\error1"
                [ ] "$57616"
        [-] MenuItem N2BelfastUsersMQuinnError
            [-] multitag "2 \\Belfast\Users\MQuinn\error1"
                [ ] "$57617"
        [-] MenuItem N3BelfastUsersMQuinnIIS
            [-] multitag "3 \\Belfast\Users\MQuinn\IIS"
                [ ] "$57618"
        [-] MenuItem N4BelfastInstallReadme
            [-] multitag "4 \\Belfast\Install\...\Readme"
                [ ] "$57619"
        [-] MenuItem Send
            [-] multitag "Send"
                [ ] "$57612"
        [-] MenuItem Exit
            [-] multitag "Exit"
                [ ] "$57665"
    [-] Menu Edit
        [ ] tag "Edit"
        [-] MenuItem Undo
            [-] multitag "Undo"
                [ ] "$57643"
        [-] MenuItem Cut
            [-] multitag "Cut"
                [ ] "$57635"
        [-] MenuItem Copy
            [-] multitag "Copy"
                [ ] "$57634"
        [-] MenuItem Paste
            [-] multitag "Paste"
                [ ] "$57637"
        [-] MenuItem PasteSpecial
            [-] multitag "Paste Special"
                [ ] "$57639"
        [-] MenuItem Clear
            [-] multitag "Clear"
                [ ] "$57632"
        [-] MenuItem SelectAll
            [-] multitag "Select All"
                [ ] "$57642"
        [-] MenuItem Find
            [-] multitag "Find"
                [ ] "$57636"
        [-] MenuItem FindNext
            [-] multitag "Find Next"
                [ ] "$57640"
        [-] MenuItem Replace
            [-] multitag "Replace"
                [ ] "$57641"
        [-] MenuItem Links
            [-] multitag "Links"
                [ ] "$57857"
        [-] MenuItem ObjectProperties
            [-] multitag "Object Properties"
                [ ] "$57860"
        [-] MenuItem Object
            [-] multitag "Object"
                [ ] "$57872"
    [-] Menu View
        [ ] tag "View"
        [-] MenuItem Toolbar
            [-] multitag "Toolbar"
                [ ] "$59392"
        [-] MenuItem FormatBar
            [-] multitag "Format Bar"
                [ ] "$59396"
        [-] MenuItem Ruler
            [-] multitag "Ruler"
                [ ] "$59397"
        [-] MenuItem StatusBar
            [-] multitag "Status Bar"
                [ ] "$59393"
        [-] MenuItem Options
            [-] multitag "Options"
                [ ] "$32776"
    [-] Menu Insert
        [ ] tag "Insert"
        [-] MenuItem DateAndTime
            [-] multitag "Date and Time"
                [ ] "$32778"
        [-] MenuItem Object
            [-] multitag "Object"
                [ ] "$57856"
    [-] Menu Format
        [ ] tag "Format"
        [-] MenuItem Font
            [-] multitag "Font"
                [ ] "$57696"
        [-] MenuItem BulletStyle
            [-] multitag "Bullet Style"
                [ ] "$32777"
        [-] MenuItem Paragraph
            [-] multitag "Paragraph"
                [ ] "$32780"
        [-] MenuItem Tabs
            [-] multitag "Tabs"
                [ ] "$32781"
    [-] Menu Help
        [ ] tag "Help"
        [-] MenuItem HelpTopics
            [-] multitag "Help Topics"
                [ ] "$57666"
        [-] MenuItem AboutWordPad
            [-] multitag "About WordPad"
                [ ] "$57664"
    [-] StatusBar StatusBar1
        [ ] tag "$59393"
        [-] DynamicText DynamicText1
            [ ] tag "#1"
        [-] DynamicText DynamicText2
            [ ] tag "#2"
        [-] DynamicText DynamicText3
            [ ] tag "#3"
    [-] CustomWin Standard
        [-] msw multitag "[AfxControlBar42u]Standard"
            [ ] "[AfxControlBar42u]$59419"
        [-] ToolBar ToolBar2
            [ ] tag "$59396"
            [-] CheckBox CheckBox1
                [ ] tag "$32799"
            [-] CheckBox CheckBox2
                [ ] tag "$32800"
            [-] CheckBox CheckBox3
                [ ] tag "$32802"
            [-] PushButton PushButton1
                [ ] tag "$32801"
            [-] CheckBox CheckBox4
                [ ] tag "$32803"
            [-] CheckBox CheckBox5
                [ ] tag "$32804"
            [-] CheckBox CheckBox6
                [ ] tag "$32805"
            [-] CheckBox BulletStyle
                [-] multitag "Bullet Style"
                    [ ] "$32777"
            [-] ComboBox ComboBox1
                [ ] tag "$165"
            [-] ComboBox ComboBox2
                [ ] tag "$166"
            [-] ComboBox ComboBox3
                [ ] tag "$207"
        [-] ToolBar ToolBar1
            [ ] tag "$59392"
            [-] PushButton New
                [-] multitag "New"
                    [ ] "$57600"
            [-] PushButton Open
                [-] multitag "Open"
                    [ ] "$57601"
            [-] PushButton Save
                [-] multitag "Save"
                    [ ] "$57603"
            [-] PushButton PushButton4
                [ ] tag "$57608"
            [-] PushButton PrintPreview
                [-] multitag "Print Preview"
                    [ ] "$57609"
            [-] PushButton Find
                [-] multitag "Find"
                    [ ] "$57636"
            [-] PushButton Cut
                [-] multitag "Cut"
                    [ ] "$57635"
            [-] PushButton Copy
                [-] multitag "Copy"
                    [ ] "$57634"
            [-] PushButton Paste
                [-] multitag "Paste"
                    [ ] "$57637"
            [-] PushButton Undo
                [-] multitag "Undo"
                    [ ] "$57643"
            [-] PushButton DateAndTime
                [-] multitag "Date and Time"
                    [ ] "$32778"
    [-] CustomWin AfxControlBar42u4
        [ ] msw tag "[AfxControlBar42u]$59422"
    [-] CustomWin AfxControlBar42u2
        [ ] msw tag "[AfxControlBar42u]$59420"
    [-] CustomWin AfxControlBar42u3
        [ ] msw tag "[AfxControlBar42u]$59421"
    [-] CustomWin Afx10000000100111001
        [ ] msw tag "[Afx:1000000:0:10011:10:0]$59397"
    [-] CustomWin RichEdit20W1
        [ ] msw tag "[RichEdit20W]$59648"
[-] // window MessageBoxClass MessageBox
    [ ] // tag "~ActiveApp/[DialogBox]$MessageBox"
    [-] // PushButton OK
        [ ] // tag "OK"
    [-] // PushButton Cancel
        [ ] // tag "Cancel"
    [-] // PushButton Yes
        [ ] // tag "Yes"
    [-] // PushButton No
        [ ] // tag "No"
    [-] // StaticText Message
        [ ] // motif tag "#2"
        [ ] // tag "#1"

 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:32
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.