使用writetofile属性时如何在UFT中为文件名添加时间戳

时间:2017-11-19 11:02:50

标签: hp-uft web-api-testing servicetestcase

当我使用多个输入(参数化)运行测试时,我尝试生成带有时间戳的文件。

请建议我如何为文件名添加时间戳 例如:C:\xxx\xxxx\xxx\Responses\xxx.xlsx到此路径我需要附加时间戳以使文件唯一。

1 个答案:

答案 0 :(得分:0)

简易选项:

Dim sTimeStamp, sPath
sPath = "C:\Path\To\My\Folder\myFile.xlsx"

' Get current time and date value and strip out the separators
sTimeStamp = Replace(Replace(Replace(Now, " ", "_"), "/", ""), ":", "")

'insert timestamp into file name
sPath = Replace(sPath, ".xlsx", "_" & sTimeStamp & ".xlsx")

Debug.Write sPath ' output is C:\Path\To\My\Folder\myFile_20112017_015827.xlsx