windend
13 years agoOccasional Contributor
Get the object by "evaluating" the string holding its name
hi, i'm reading findchild method in html help file. The example is given as below. However, when i execute this sub and try to use wndNotepad.Exsits before Log.Picture line to verify whether the notepad object is located correctly, testcomplete return an err msg says
"An exception occurred in the "findChildwithName" unit at line 12: Microsoft VBScript runtime error.Object required: 'wndNotedpad' ". I also tried this usage in some other ways, testcomplete can't find the object. My question is what the correct way to operate the objects got by "evaluating" the string holding its name? Thank you.
"An exception occurred in the "findChildwithName" unit at line 12: Microsoft VBScript runtime error.Object required: 'wndNotedpad' ". I also tried this usage in some other ways, testcomplete can't find the object. My question is what the correct way to operate the objects got by "evaluating" the string holding its name? Thank you.
Sub NotepadTest
Dim strObjName, p, wndNotepad
strObjName = "Window(""Notepad"", ""* - Notepad"")"
' Store the parent object to a variable
Set p = Sys.Process("notepad")
' Obtain the object by its Name property
' p is the name of the variable that holds the parent object
Set wndNotepad = Eval("p." & strObjName)
Log.Picture wndNotepad, "Notepad window", wndNotepad.FullName
End Sub