51Testing软件测试论坛

标题: QuickTestPro:Running log for QTP [打印本页]

作者: pcl2004_27    时间: 2006-10-30 14:18
标题: QuickTestPro:Running log for QTP
Description

      A small script that works like printf in WinRunner for QTP


Solution

      Hope this would help others... I was having problems with this and posted on Forum and there on came up with this sort of solution.
Function UniqueMe()
dim myDate, myTime, Unique, TempArray
myTime=split(time(),":")
myDate=split(FormatDateTime(date(),vbshortdate),"/")
TempArray=split(myTime(2)," ")
Unique=myDate(0)&myDate(1)&myDate(2)&myTime(0)&myTime(1)&TempArray(0)&TempArray(1)
UniqueMe=Unique
End Function

Function CreatePrintLog()
dim FileID, FileSysObj, FileName
FileID = UniqueMe()
FileName="c:\" &FileID &".txt"
' Create a File Object

Set FileSysObj = CreateObject("Scripting.FileSystemObject")
' not required but its good to have
do while FileSysObj.FileExists(FileName) = TRUE
FileID = UniqueMe()
FileName="c:\" &FileID &".txt"
Loop
FileSysObj.CreateTextFile FileName, True
OpenPrintLog(FileName)
CreatePrintLog=FileID
End Function

Function OpenPrintLog(FileName)
' load the shell execute functions
Extern.Declare micLong, "ShellExecute","shell32.dll","ShellExecuteA", micLong, micString, micString, micString, micString, micLong
Const SW_RESTORE = 9
rc=extern.ShellExecute (0,"open","notepad.exe",FileName,"",SW_RESTORE)
End Function
dim File
File=CreatePrintLog()
Window("text:="&File &".*").WinEditor("nativeclass:=Edit").Type "asdfs" + micReturn




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2