Micro Focus QTP (UFT) Forums
How to generate QTP report in a new file(html)? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to generate QTP report in a new file(html)? (/Thread-How-to-generate-QTP-report-in-a-new-file-html)



How to generate QTP report in a new file(html)? - yogesh kancherla - 10-18-2012

Hi,,
I have code which will create a html file for reporting and updating logs in the report. but everytime i run the script this report is overwritten.
My requirement is everytime i run the script it should generate a new file and NOT overwritten.
Please help with the code.


RE: How to generate QTP report in a new file(html)? - harishshenoy - 10-18-2012

Hi ,

While creating a HTML file why cant you use 'now()' property to give unique name to the file.

like :

Code:
FileName = "D:\HtmlReport_" &  replace(replace(replace(now() , "/" , "_") , ":" , "_") , " " , "_") & ".html"
and then use it in the file creation

Code:
Set objFS_TestSet = CreateObject("Scripting.FileSystemObject")
Set objReport_Set = objFS_TestSet.OpenTextFile(FileName, 2, True)

Thanks,
Harish


RE: How to generate QTP report in a new file(html)? - yogesh kancherla - 10-19-2012

Harish, i tried below code but its saying "path not found"

Code:
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
path1="D:\QTP_R22\DDF\Report\gsReportFile" & now() & ".html"
Set objTextFileObject= objFileSystemObject.CreateTextFile(path1,True)

What might be the issue?


RE: How to generate QTP report in a new file(html)? - ssvali - 10-19-2012

Try the below

Code:
TS = replace(replace(replace(now() , "/" , "_") , ":" , "_") , " " , "_")
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
path1="D:\QTP_R22\DDF\Report\gsReportFile_"&TS& ".html"
Set objTextFileObject= objFileSystemObject.CreateTextFile(path1,True)



RE: How to generate QTP report in a new file(html)? - harishshenoy - 10-19-2012

Hi ,

Here u used only 'now()' that includes 'space' in that also....U need to replace the space with any other charectors like '_' , because if any space encounter in the URL then browser will not recognize the path of that , u can avoid space using 'replace' key word , like I have mentioned in the previous post , use the below code in place of 'now()' (just replace now() with the below code)

like :
replace(replace(replace(now() , "/" , "_") , ":" , "_") , " " , "_")

you will be able to get the report sucessfully.


Thnanks ,
Harish


RE: How to generate QTP report in a new file(html)? - yogesh kancherla - 10-21-2012

Thanks a alot. its working.Smile



Thanks a lotSmile its workingSmile