Download summary PDF report for a job in Java
Sometimes it is needed to download a Summary PDF report for a Job, which contains tests from more than one driver execution session.
This is possible via the Smart Reporting API (see PDF Formatted Report).
Step-by-step guide
- Utilize ReportiumExportUtils in your project;
-
Add following method there:
Copy/**
* Downloads the job summary PDF report
*
* @param jobSummaryPdfPath local path that the downloaded report will be saved to
* @param jobName the job name of the report
* @param jobNumber the job number of the report
* @throws URISyntaxException
* @throws IOException
*/
public static void downloadJobSummaryReport(Path jobSummaryPdfPath, String jobName, String jobNumber) throws URISyntaxException, IOException {
System.out.println("Downloading PDF for job: " + jobName + ", # " + jobNumber);
URIBuilder uriBuilder = new URIBuilder(REPORTING_SERVER_URL + "/export/api/v1/test-executions/pdf");
uriBuilder.addParameter("jobName[0]", jobName);
uriBuilder.addParameter("jobNumber[0]", jobNumber);
System.out.println(uriBuilder.build());
downloadPdfFileToFS(jobSummaryPdfPath, uriBuilder.build());
} -
Call it in your project as per the example in PdfDownloadCodeSample
Copy//change accordingly or obtain during runtime from test environment
String jobName = "<job_name>";
String jobNumber = "<job_number>";
String downloadFolder = "./perfectoReports";
Path jobSummaryPdfPath = Paths.get(downloadFolder, jobName + "_" + jobNumber + ".pdf");
ReportiumExportUtils.downloadJobSummaryReport(jobSummaryPdfPath, jobName, jobNumber);