How to PDF and Send Email - Ranorex 8.1.1

Best practices, code snippets for common functionality, examples, and guidelines.
riagarwal
Posts: 5
Joined: Thu Aug 27, 2015 3:44 pm

How to PDF and Send Email - Ranorex 8.1.1

Post by riagarwal » Tue Jun 26, 2018 8:13 pm

Hello All,

I am getting error message

"The Key is not present in the Dictionary"
using Report to PDF with Ranorex 8.1.1. It was working fine with 8.0

Please assist.
Attachments
Ranorex8.JPG
Error Message
Ranorex8.JPG (95.92 KiB) Viewed 367 times

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

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by Support Team » Thu Jun 28, 2018 6:51 pm

Hi Riagarwal,

I hope my latest email resolved your issue. I have copied the solution below in case anyone else comes across this thread with the same issue.
This issue is occurring because you are using an old ReportToPDF module in your test suite instead of the new Automation Helper’s ReportToPDFModule (see pictures below). Remove the old ReportToPDF module in your project and use the new ReportToPDFModule included in the Automation Helpers project to resolve this issue.
1.png
1.png (20.66 KiB) Viewed 352 times
2.png
2.png (16.93 KiB) Viewed 352 times
Cheers,
Ned
.
Image

hellboy81
Posts: 22
Joined: Sun Dec 10, 2017 8:52 pm

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by hellboy81 » Thu Jul 05, 2018 7:54 am

I am using the last Ranorex Automation Helpers with Ranorex.PDF.exe version 1.0.11.00 with .NET 4.0 with Ranorex Studio 8.0 and sometimes I got this message.

As I mentioned there are problems in input parameters passed to Ranorex.PDF.exe.

The exception message is too broad and it is hard to localize reason:

Code: Select all

Unhandled Exception: 
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Ranorex.PDF.Container.InitContainerTypeSpecificProperties(Image UIIcon, Font font, Color backgroundColor)
   at Ranorex.PDF.Container.InitConfiguration()
   at Ranorex.PDF.Container..ctor(XmlNode container, Section section, Single level, Single rightMargin, Section headerSec, String type)
   at Ranorex.PDF.PDFCreator.CreateTestCases(List`1 testSuiteChilds)
   at Ranorex.PDF.PDFCreator.CreateTestCases(List`1 testSuiteChilds)
   at Ranorex.PDF.PDFCreator..ctor(XmlNode rootNode, String xml, RanorexGraphics rg)
   at Ranorex.PDF.Program.Main(String[] args)
Can you fix it?

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

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by Support Team » Thu Jul 05, 2018 7:13 pm

Hi Hellboy81,

In most cases, this issue occurs due to an old ReportToPDF reference. Try the below and see if it resolves your issue:
  1. Remove the current Ranorex Automation Helpers project (right-click in the project view > Remove)
  2. Remove any Ranorex.PDF references in your project(s) (right-click the reference in the "References" folder > Remove)
  3. Remove any ReportToPDF modules in your project(s) and test suite (right-click module in the project view > Delete)
  4. Empty your output folder (Ranorex Studio > Project (on the toolbar) > Open output folder > backup and delete all items)
  5. Re-add the Ranorex Automation Helpers project
  6. Update the Ranorex Automation Helpers
  7. Add the ReportToPDFModule from the Ranorex Automation Helpers project to your project's test suite's [TEARDOWN] region
    1.png
    1.png (13.94 KiB) Viewed 322 times
I hope this helps resolve your issue! If you still are experiencing this error after trying the above, please provide a compressed copy of your solution and I will be happy to take a closer look. You can create a support ticket if you wish to further troubleshoot this privately.

Cheers,
Ned
.
Image

naveenkumar.narra
Posts: 2
Joined: Sun Jul 22, 2018 11:08 pm

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by naveenkumar.narra » Mon Jul 23, 2018 4:19 pm

I would like to know how to use email module & report to PDF for sending the report on email . Please help me asap.
Automation helpers has Email Module & Report to PDF but the problem is when i am trying to use them they are not working properly.
I hope some extra configuration has to be done for trigger them rather them drag and drop on tear.

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

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by Support Team » Mon Jul 23, 2018 8:42 pm

Hi naveenkumar.narra,

To use the EmailModule, simply add it to your test suite's teardown region, and set the required parameters (double click Unbound variables: 13 > Auto-Create > Auto-Bind > enter Values).

2.png
2.png (3.05 KiB) Viewed 270 times

If you continue to experience issues, please provide details on why it is not working and I will be happy to further assist you (such as any specific errors). A copy of the failed Ranorex Report (compressed) will be beneficial to help us understand what is occurring and why it is not working properly. Also, what are your parameters set to (example pictured below)?

1.png
1.png (16.92 KiB) Viewed 270 times

Note, you do not need ReportToPDFmodule to email a PDF copy of the report. Simply set SendPdfReportOnComplete set to true inthe EmailModule's parameters.

Cheers,
Ned
.
Image

naveenkumar.narra
Posts: 2
Joined: Sun Jul 22, 2018 11:08 pm

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by naveenkumar.narra » Tue Jul 24, 2018 8:29 pm

Thanks for the steps.

After testing what i understood is the email gets trigger (with PDF report ) only when we run the Test Case on Test Suite Level but if we run the test case directly there is not email with the report. I hope this is functionality.If i need to get email with report after each individual test case we need to write our own email stuff.

For better understanding i have created a test case under Test Suite then i have added a recording module with a failure scenario (report.log(Failure)) for that test case and in tear used the Email module.

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

Re: How to PDF and Send Email - Ranorex 8.1.1

Post by Support Team » Tue Jul 24, 2018 9:03 pm

Hi naveenjumar.narra,

I am happy I was able to help. The EmailModule should only be called once at the very end of your test, ideally in the test suite's tear-down region. This is because it must finalize the report file prior to emailing/converting to a PDF which prevents any more data from being added to it.

As long as it is in the tear-down region of your test suite, it will work for when running any variation of test cases, even if it is only one. Both of the below scenarios will run the EmailModule, even if there is a failure in the test.

Code: Select all

MyProject - Test Suite
☑ TestCase1
     MyRecordingModules
☑ TestCase2
     MyRecordingModules
☑ TestCase3
     MyRecordingModules
[TTEARDOWN]
     EmailModule

Code: Select all

MyProject - Test Suite
☐ TestCase1
     MyRecordingModules
☑ TestCase2
     MyRecordingModules
☐ TestCase3
     MyRecordingModules
[TTEARDOWN]
     EmailModule
Cheers,
Ned
.
Image