How to disable report screenshots by code

Class library usage, coding and language questions.
sstellaccio
Posts: 3
Joined: Thu Sep 14, 2017 3:09 pm

How to disable report screenshots by code

Post by sstellaccio » Thu Sep 14, 2017 3:25 pm

Hi,

I'm using Ranorex 7.0.1 and I'm needing to disable the screenshots of the report inside a code module, but only for a single validation.
I have some code that invokes some web service and evaluate the result. If some error is detected, I want to throw an error message on the report, mark the test case as failed, and stop the test execution and continue with next one.
I found that Ranorex.Validate.Fail("My error message"); does the thing I need, but it also produce a Screenshot (totally useless) in the report. I want to disable the screenshots but only for that sentence, but I want the screenshots for the rest of the test case (other sentences interacts with the UI and the screenshots are very usefull).

I can't find any reference about the code to do that. I tried the following code (probably it's wrong):

Ranorex.Validate.ResultOption vResultOption = new Ranorex.Validate.ResultOption();
vResultOption = Ranorex.Validate.ResultOption.Never;
Ranorex.Validate.Options vValidateOptions = new Validate.Options(vResultOption);

Ranorex.Validate.Fail("My erro message", vValidateOptions);

But nothing happened. The error on the report stills include the screenshot.

I would appreciate if someone could help me with that. Is very important to avoid taking screenshot on these senteces due to the overhead of snapshot and storage those pictures.

Thanks in advance!
Regards,

Simón

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

Re: How to disable report screenshots by code

Post by Support Team » Fri Sep 15, 2017 9:13 am

Hello Sstellaccio,

Thank you for your post.
In order to turn off tracing screenshots, you might use the following line of code:

Code: Select all

Ranorex.Core.Reporting.TestReport.EnableTracingScreenshots=false;
I hope this helps.

regards,
Stephan
.
Image

sstellaccio
Posts: 3
Joined: Thu Sep 14, 2017 3:09 pm

Re: How to disable report screenshots by code

Post by sstellaccio » Tue Sep 19, 2017 7:26 pm

Support Team wrote:Hello Sstellaccio,

Thank you for your post.
In order to turn off tracing screenshots, you might use the following line of code:

Code: Select all

Ranorex.Core.Reporting.TestReport.EnableTracingScreenshots=false;
I hope this helps.

regards,
Stephan
Hi Stephan,

It worked perfectly for the purpouse. Thanks for your assistance. It was easier than I thought.

Best regards,

Simón