Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can you identify dynamically created objects?

How can you identify dynamically created objects?

Firstly, dynamically created objects are not visible to SilkTest until they are created. This means we have to test to see if the object exists before we can test against it.

The testcase Chk_Changes() below uses a text file to store the objects of an application. The first time it is run all objects are new, therefore it will print out all the objects. The next time it is run it will compare what has changed and print the changes out.

This is achieved with the use of the GetChildren() Method to retrieve all the objects of the application, FileWriteLine() to write the information to a text file and ListRead() to read the information from the text file to compare the list against the application. (ExampleApp requires to be changed for your application)

[-] testcase Chk_Changes()
    [ ] LIST OF WINDOW lwDynamTxt,lwNewObjects
    [ ] LIST OF STRING lsFile
    [ ] STRING sFileName,sPageList
    [ ] WINDOW wTemp
    [ ] BOOLEAN bExists,bFound
    [ ] HFILE FileHandle
    [ ] 
    [ ] //File that contains results   
[ ] sFileName="C:\PageObjects.txt"
    [ ] 
    [ ] //Obtaining all the objects in browser window and putting them in a list   
[ ] lwDynamTxt=ExampleApp.getchildren()
    [ ] 
    [ ] //Test if results file exists
    [ ] bExists = SYS_FileExists (sFileName)
    [ ] 
    [ ] //If file does not exist create it
    [-] if bExists == False
        [ ] ListWrite (lsFile, sFileName)
        [ ] 
    [ ] //Read Information From File
    [ ] ListRead (lsFile, sFileName)
    [ ] 
    [ ] //check window list against file
    [-] for each wTemp in lwDynamTxt
        [ ] bFound = FALSE
        [-] for each sPageList in lsFile
            [-] if [STRING]wTemp == sPageList
                [ ] bFound = TRUE
        [-] if bFound == FALSE
            [ ] //Print out new objects
            [ ] Print("New Object",[STRING]wTemp)
            [ ] //Add new objects to file
            [ ] FileHandle = FileOpen (sFileName, FM_APPEND)
            [ ] FileWriteLine (FileHandle, [STRING]wTemp)
            [ ] FileClose (FileHandle)

Old KB# 21190


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:17
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.