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)