未来已来
SilkTest 脚本代码实例赏析
上一篇 /
下一篇 2008-09-25 09:26:56
/ 个人分类:测试生活
获得对象中所有的子对象?
public LIST OF WINDOW GetChildObjects(Window wContainer, DATACLASS dcObject)
[ ] // To get All child objects.
[ ] // Used recursive method.
[ ] LIST OF WINDOW lwndObjects, lwTemp1, lwTemp2
[ ] LIST OF WINDOW lwndChildren = {...}
[ ] WINDOW wParent, wChild, wTemp
[ ]
[-] do
[-] if (wContainer.Exists (10))
[ ] lwndChildren = wContainer.GetChildren (TRUE, FALSE)
[ ]
[-] for each wChild in lwndChildren
[-] if wChild.IsOfClass(dcObject)
[ ] ListAppend (lwndObjects,wChild)
[-] else
[ ] lwTemp1 = wChild.GetChildren(TRUE, FALSE)
[-] if (ListCount(lwTemp1) > 1)
[ ] lwTemp2 = GetChildObjects(wChild,dcObject)
//To get particular objects
[-] if (ListCount(lwTemp2) > 0)
[ ] ListMerge (lwndObjects, lwTemp2)
[-] else
[ ] Print ("Container {[STRING]wContainer} is not available.")
[+] except
[ ] ExceptLog ()
[ ]
[ ] return lwndChildren
获得ip地址?
[+] public String GetIpAddress(String sMachineName)
[ ] //To get IP Address for the particular machine in Network
[ ] List of String lsOutput
[ ] String sCommand
[ ] String sTemp, sItem
[ ] String sResult = NULL
[ ] Boolean bResult = FALSE
[ ] Integer iPos1, iPos2
[ ]
[ ] sCommand = "ping -a {sMachineName}"
[ ] Sys_Execute (sCommand,lsOutput)
[ ]
[ ] //ListPrint (lsOutput)
[-] for each sItem in lsOutput
[-] if (MatchStr("*pinging*", sItem))
[ ] bResult = TRUE
[ ] break
[ ]
[-] if (bResult)
[ ] iPos1 = StrPos ("[", sItem)
[ ] iPos2 = StrPos ("]", sItem)
[-] if ((iPos1 > 0) && (iPos2 > 0))
[ ] sResult = SubStr(sItem,iPos1+1, iPos2-iPos1-1)
[ ] Print ("Found IP Address: {sResult}")
[ ] return sResult
获得子文件夹?
[ ]
[+] LIST OF STRING GetDirectories (STRING sDirPath)
[ ]
[ ] LIST OF FILEINFO lfFiles
[ ] FILEINFO file
[ ] LIST OF STRING lsDirsFound = {...}
[ ]
[ ]
[-] if ! SYS_DirExists ( sDirPath )
[ ] LogWarning ( "Cannot find '{sDirPath}' on file system" )
[ ]
[ ] lfFiles = SYS_GetDirContents (sDirPath)
[ ]
[-] for each file in lfFiles
[-] if (file.bIsDir)
[ ] ListAppend (lsDirsFound, sDirPath + "\" + file.sName)
[ ]
[ ] ListSort (lsDirsFound)
[ ]
[ ] return lsDirsFound
相关阅读:
- 回复:如何进入软件测试行业来信 - 三 (pcl2004_27, 2008-8-13)
- 接到一个电话 (pcl2004_27, 2008-8-18)
- 面子与培训 (pcl2004_27, 2008-8-19)
- 探子 (pcl2004_27, 2008-8-25)
- (转)献给正在为面试而奋斗的七期同学们 (pcl2004_27, 2008-8-25)
- 轮回 - 北京 - 上海 - 北京 (pcl2004_27, 2008-9-09)
- 高薪的秘诀 (pcl2004_27, 2008-9-12)
- 一个开心的秘密 (pcl2004_27, 2008-9-12)
- 遗憾 (pcl2004_27, 2008-9-21)
- 纪录51Testing成长历程与我 (pcl2004_27, 2008-9-22)
收藏
举报
TAG:
测试生活