Search code examples
c#.netqtphp-uft

How to use C# export QTP result to PDF automatically


I'm writing a C# program to run QTP.

Now my program can trigger QTP automatically and send the result to my mailbox. But this result is HTML, i find that QTP can export a PDF result.

so, here is my code.

qtpAutoReport = qtpApp.Options.Run.AutoExportReportConfig;
qtpAutoReport.AutoExportResults = true;
qtpAutoReport.StepDetailsReport = true;
qtpAutoReport.DataTableReport = false;
qtpAutoReport.LogTrackingReport = false;
qtpAutoReport.ScreenRecorderReport = false;
qtpAutoReport.SystemMonitorReport = false;
qtpAutoReport.StepDetailsReportFormat = "Short";
qtpAutoReport.ExportLocation = AutoExportPath;
qtpAutoReport.ExportForFailedRunsOnly = false;
qtpAutoReport.StepDetailsReportType = "PDF";

When i use this code qtpAutoReport.StepDetailsReportType = "HTML"; My program can run successfully, and i can find this HTML file on my disk.

But, when i use this code qtpAutoReport.StepDetailsReportType = "PDF"; After QTP test is over, i can't any file on my disk. So my question is why QTP can't export result when i set StepDetailsReportType as "PDF"?


Solution

  • There does seem to be an issue with UFT, I found a method that works for GUI tests(vbscript), give it a try with Service Test (c#).

    All options are the same as your example, with one addition:

    uftObject.Options.Run.ViewResults = True

    This tells UFT that you want to view the results after completion. Without this flag I get no PDF result, with it the file is waiting at the export path. Option Explicit Dim uftObject, qtResultsOpt
    Set uftObject=CreateObject("Quicktest.application") uftObject.Launch uftObject.Visible = True Set qtResultsOpt = uftObject.Options.Run.AutoExportReportConfig Dim AutoExportPath AutoExportPath = "C:\Users\paxic\Desktop\stackoverflow\results" qtResultsOpt.AutoExportResults = true qtResultsOpt.StepDetailsReport = true qtResultsOpt.DataTableReport = false qtResultsOpt.LogTrackingReport = false qtResultsOpt.ScreenRecorderReport = false qtResultsOpt.SystemMonitorReport = false qtResultsOpt.StepDetailsReportFormat = "Short" qtResultsOpt.ExportLocation = AutoExportPath qtResultsOpt.ExportForFailedRunsOnly = false qtResultsOpt.StepDetailsReportType = "PDF" uftObject.Open "C:\Users\JMorley\Desktop\stackoverflow\ExampleOne" qtResultsOpt.AutoExportResults = True uftObject.Options.Run.ViewResults = True uftObject.Test.Run