Ranorex automation helpers Generate pdf to a location

Ask general questions here.
simmisj
Posts: 19
Joined: Tue Feb 27, 2018 10:12 am

Ranorex automation helpers Generate pdf to a location

Post by simmisj » Fri Apr 13, 2018 12:49 pm

Hi.
I am generating pdf reports using the automation helpers and the module called ReportToPDFModule.cs.
It generates the pdf file and puts it in the reports folder.
I am wondering if I can specify the path to which it will write the report to? I want to write it to a different machine on my network.

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex automation helpers Generate pdf to a location

Post by Support Team » Mon Apr 16, 2018 4:23 am

Hi simmisj,

ReportToPDF uses the same output path as the normal report formats, so by changing that path you can specify where the PDF will go. We typically recommend against saving items to network locations as there can be issues caused by permissions and or network quirks. If you wish to learn more about reporting and how to specify the output location for the report, please see the below:

https://www.ranorex.com/help/latest/les ... teSettings
https://www.ranorex.com/help/latest/lesson-8-reporting

I hope this helps and I look forward to hearing from you!

-Jon!
.
Image

simmisj
Posts: 19
Joined: Tue Feb 27, 2018 10:12 am

Re: Ranorex automation helpers Generate pdf to a location

Post by simmisj » Mon Apr 16, 2018 9:56 am

But that will put all of the reporting files to that same folder.
What I would like to be able to do is putting the PDF report into a specific folder and the rest of it to another. The reason is because the "business" people only need the pdf generated report while the other files are more interesting for us developers. I was hoping to skip writing my own software to filter this out.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex automation helpers Generate pdf to a location

Post by Support Team » Mon Apr 16, 2018 10:25 pm

Hi simmisj,

Well since you want to move the PDF report you need to wait until it is generated. To have code execute after the test is technically finished, you can edit Program.cs. Below I have used an extremly basic example of using XCopy to move all PDFs from the source directory (my reporting directory) to my destination directory:

Code: Select all

Program.cs

using System;
using System.Threading;
using System.Drawing;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using WinForms = System.Windows.Forms;
using System.Diagnostics;

using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Reporting;
using Ranorex.Core.Testing;

namespace testingPDF
{
    class Program
    {
        [STAThread]
        public static int Main(string[] args)
        {
            // Uncomment the following 2 lines if you want to automate Windows apps
            // by starting the test executable directly
            //if (Util.IsRestartRequiredForWinAppAccess)
            //    return Util.RestartWithUiAccess();

            Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
            int error = 0;

            try
            {
                error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
                CopyPDF();
            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occurred: " + e.ToString());
                error = -1;
            }
            return error;
        }
        
        private static void CopyPDF()
        {
            string source = @"C:\Users\jwilbur\Desktop\hudge\*.pdf ";
            string destination = @"C:\outputPDF\";
            
            //Copy PDF(s)
            var processInfo = new ProcessStartInfo();
            processInfo.CreateNoWindow = true;
            processInfo.RedirectStandardError = true;
            processInfo.UseShellExecute = false;
            processInfo.RedirectStandardOutput = true;
            processInfo.RedirectStandardInput = true;
            processInfo.FileName = "xcopy";
            processInfo.Arguments = source + destination;            
            var process = Process.Start(processInfo);
            Console.WriteLine("Copying PDF...");
            process.WaitForExit();
        }
    }
}

Again the above example will copy all PDFs in the source directory but this can easily be edited for targeted copying.

I hope this helps!

-Jon
.
Image