Page 1 of 1

How to disable report screenshots by code

Posted: Thu Sep 14, 2017 3:25 pm
by sstellaccio
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

Re: How to disable report screenshots by code

Posted: Fri Sep 15, 2017 9:13 am
by Support Team
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

Re: How to disable report screenshots by code

Posted: Tue Sep 19, 2017 7:26 pm
by sstellaccio
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