51Testing软件测试论坛

标题: 如何更便捷地获得当前test路径 [打印本页]

作者: joseph_wh    时间: 2007-8-30 00:13
标题: 如何更便捷地获得当前test路径
我想知道QTP里面有没有更方便,更简短的获得当前运行的test的路径的方法。

这是我自己写的,貌似偏长偏繁了点。
不知道谁有更便捷的没?

[code]
'Create a temp file which named testfile.txt (the path as follow scripts)
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("C:\QtpWorkFolder\Path\TempPath\testfile.txt", True)
MyFile.WriteLine("This is a test.")
MyFile.Close

Dim reportPath, testPath
'Get the path of current test's report
reportPath = Reporter.ReportPath
'Show me the report path
MsgBox ("The Test Report Path is: " & reportPath)
'Cut the folder name of the result
testPath = Right(reportPath, 2)
If testPath <= "99" and testPath >= "10" Then
        testPath = Left(reportPath, Len(reportPath) - 5)
Else
        testPath = Left(reportPath, Len(reportPath) - 4)
End If
'Show me the test path
MsgBox ("The Test Path is: " & testPath)[/code]
作者: yabest    时间: 2007-8-30 00:49
hehe, QTP环境变量里有现成的,好像叫TestPath啥的!
作者: hsjzfling    时间: 2007-8-30 01:06
直接调用系统环境变量: Environment("TestDir")
作者: yuandjing    时间: 2007-8-30 11:54
楼主可以点击“file”->"setting"->"environment"里面列出的build-in的所有的列表就是系统环境变量
作者: zhuyuancan    时间: 2007-8-30 14:10
msgbox environment.Value("TestDir")
作者: jackymail    时间: 2007-8-30 16:01
楼上的你写的不对。
这个帖子有点搞笑,楼主要分享成就,结果被大家一顿纠正sdlkfj3
作者: danmy    时间: 2007-8-30 16:27
呵呵,楼主精神可嘉

不过——
作者: joseph_wh    时间: 2007-8-30 17:58
原帖由 jackymail 于 2007-8-30 16:01 发表
楼上的你写的不对。
这个帖子有点搞笑,楼主要分享成就,结果被大家一顿纠正sdlkfj3


其实,我是想知道更简便的方法。
倒不是来分享的,而是告诉大家我现在用的比较麻烦。别和我用一样的。
有简单的一定用简单的,便于维护。
作者: walker1020    时间: 2007-8-30 23:54
楼主可以使用一下 #3 和#5 的方式试试
作者: joseph_wh    时间: 2007-8-30 23:56
已经用了,在这方面效果一样。
作者: walker1020    时间: 2007-8-31 00:12
原帖由 joseph_wh 于 2007-8-30 23:56 发表
已经用了,在这方面效果一样。


它们的效果本来就是一样的,就像获得某个 sheet 的某个ParameterID 的值一样,你可以使用
DataTable.Value(ParameterID [, SheetID])

也可以使用 DataTable(ParameterID [, SheetID]) 。
你可以把后面一个理解为前面一个的缩写形式。
作者: jackymail    时间: 2007-8-31 10:13
哦,原来这样。。下次我不发言。抱歉。
作者: llytaiyang    时间: 2007-8-31 10:23
5楼的方法快捷又简洁!爽
作者: joseph_wh    时间: 2007-8-31 10:24
呃...
童言无忌嘛。
作者: walker1020    时间: 2007-8-31 10:30
原帖由 jackymail 于 2007-8-31 10:13 发表
哦,原来这样。。下次我不发言。抱歉。


呵呵!童言无忌!




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