Managing Tests that Print? Adding a Printer?

Ask general questions here.
Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Managing Tests that Print? Adding a Printer?

Post by Fergal » Thu Oct 06, 2016 11:26 am

Ranorex 6.1, Windows 7

I have Ranorex test cases, which print lots of paper. To deal with these I have used the following two methods:

1. Added a Dummy Printer / Test Printer to my machine and set it as the default printer
2. Printed to OneNote

My issue is that I need to share these tests with others and to do that I want to:

1. Check if they have Test Printer installed
2. if Yes, set Test Printer as default
3. if No add a Test Printer to their machine.

How can I create a module or method to "add a Test Printer to their machine"?

Are there better ways for managing tests that result in paper being printed?

Thanks!

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Managing Tests that Print? Adding a Printer?

Post by krstcs » Thu Oct 06, 2016 3:28 pm

This is more of a .NET question than a Ranorex question because you are going to have to use code for this. Have you searched the web for how to add a printer using .NET?

Another option is to make a PowerShell script that does it, add the script to your project, and run the PS script from inside your Ranorex test. Note that you will have to make sure that your script is written to the lowest version of PowerShell that would be available on your users' systems so you don't run into other errors. This might be a good reason to do it in .NET though because you know that .NET will be installed.
Shortcuts usually aren't...

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Managing Tests that Print? Adding a Printer?

Post by Fergal » Thu Oct 06, 2016 4:30 pm

Thanks krstcs.
Have you searched the web for how to add a printer using .NET?
Yes, have been looking at some ideas, such as this and this. I'm not familiar with ManagementClass and haven't got it to work yet.

Another option is to make a PowerShell script that does it
Not something I am familiar with, so will do some research on that.

Thanks again!

User avatar
Aracknid
Posts: 388
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Managing Tests that Print? Adding a Printer?

Post by Aracknid » Tue Oct 11, 2016 4:08 pm

Ug... print testing. I hate that. I hate it so much that I pushed back and simply said "There are better things I can spend my time on with respect to automation that will have more bang for the buck.", or in other words, some things just shouldn't be tested using automation... Of course, that's my opinion and for the product I work on in which printing was NOT a major feature or high priority, it made sense. Could be different for you.

When I did do printer testing in the past, here's what I did. I offer this only as another thought process, not a solution....

I found a free program that installed as a printer but actually took screen shots. I'd "print" to this "printer" and have the files saved as BMP files. Then I'd compare the BMP files to previous BMP files from previous runs. They should be a perfect match. Most times they were... I had to block out some parts of the image (date and time stamps for example). I often had issues with items being shifted by a pixel or 2. I also found different screen resolutions had impact too. I became to hands on management to make it worth while (as it never actually found issues)

Another thing I attempted was running through OCR (I was specifically looking for a footer and header being printed). This didn't work well because the OCR was unreliable and would get the exact same words on multiple pages incorrectly on some pages.

I ultimately told management this was a waste of my time.

Regards,

Aracknid.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Managing Tests that Print? Adding a Printer?

Post by krstcs » Tue Oct 11, 2016 5:05 pm

While I would normally agree that printing is by definition a manual process, there are times when we need to capture the printed output through automation.

For example, I primarily test a Point-Of-Sale (POS) system the prints receipts. These receipts are required by accounting for doing validation before a release is OKed. I'm fortunate that my devs added a fake printer to our system that just captures what would have been printed on the receipt tape to a Java text box, from which I can copy it an store it with my test results for each test scenario.

I also have to test a back-end UI system that doesn't have the fake printer, so printing its order confirmation pages requires a real printer driver that will print to text files which I can attach to my reports and/or store in the DB with the results, again for accounting review.

I have a system that allows them to review specific test runs/scenarios including all of the "printed" documents that they need, without us printing anything. The system is created in MS Lightswitch HTML and my data is all in SQL Server. Works wonderfully.
Shortcuts usually aren't...