|
Google搜索"QTP 共享",文章里有4中方式
不过这个变量是一个action及其被调用的action之间进行共享的。
如果在test set级别,想做共享变量,可以 用文件保存,代码如下:- Function func_GetGlobalVar (varName )
-
- func_GetGlobalVar = "None"
-
- ' hostname = string$ (100,chr$(10))
- ' Result = func_ToolGetComputerName(hostname,100 )
- filePath = "c:\" + varName
- Dim fso, myfile, tmp
- If IsExitAFile(filePath) Then
- Set fso=CreateObject("scripting.FileSystemObject")
- Set myfile=fso.openTextFile(filePath,1,false)
- tmp=myfile.readline
- myfile.close
- else
- tmp = "None"
- end if
- func_GetGlobalVar = tmp
-
- End Function
- Function func_SetGlobalVar (varName, varValue )
-
- func_SetGlobalVar = 0
-
- 'hostname = string$ (100,chr$(10))
- 'Result = func_ToolGetComputerName(hostname,100 )
- filePath = "c:\" + varName
- If IsExitAFile(filePath) Then
- DeleteAFile(filePath)
- Else
- 'CreateAFile(filePath)
- End If
- Dim fso, myfile
- Set fso=CreateObject("scripting.FileSystemObject")
- Set myfile=fso.openTextFile(filePath,8,true)
- myfile.writeline varValue
-
- func_SetGlobalVar = 1
-
- End Function
复制代码 |
|