Controlling Screenshots Saved in Reports Folder

Ask general questions here.
kgowans
Posts: 2
Joined: Tue Feb 28, 2017 2:15 pm

Controlling Screenshots Saved in Reports Folder

Post by kgowans » Tue Feb 28, 2017 2:29 pm

Hello,

I was wondering if there was a way to control what screenshots are saved to the Reports folder?

Currently, all screenshots taken during a my image validation tests are stored and it is taking up a lot of space. I'd like to only backup the image when a test fails the validation and not when a test passes.

Thank you for any help your able to provide,

Kim

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: Controlling Screenshots Saved in Reports Folder

Post by qwertzu » Wed Mar 01, 2017 2:48 pm

Hello kgowans,

There is a property for image validation actions called "Report Screenshot".
If you choose "onFail", Screenshots should be saved only if the validation fails.

I hope, this will help.
You do not have the required permissions to view the files attached to this post.

kgowans
Posts: 2
Joined: Tue Feb 28, 2017 2:15 pm

Re: Controlling Screenshots Saved in Reports Folder

Post by kgowans » Thu Mar 02, 2017 2:41 pm

Thanks! That is definitely something I didn't know I could do. Is it possible to use this method if I'm using UserCode for image Validation?

Here is the code I'm using to validate:

Code: Select all

public void validatePages()
        {
        	string expectedPicLocation;

        	for(int iteration = 1; iteration < this.numberOfPages + 1; iteration++)
			{
		  		Imaging.FindOptions findOption = new Imaging.FindOptions(1.0);

		  		expectedPicLocation = this.goodFilePath + nameOfFile +  iteration.ToString() + ".png";

		    	Bitmap bmp1 = Ranorex.Imaging.Load(expectedPicLocation); 
		    	try
		    	{
			    	Validate.ContainsImage(repo.Common_Office_Popups.PrintPreviewItems.document, bmp1,findOption);
			        Delay.Milliseconds(100);
		    	}
		    	catch(Exception e)
		    	{
		    		Report.Log(ReportLevel.Error, "Validation Error", "page "+iteration.ToString(), repo.Common_Office_Popups.PrintPreviewItems.nextPageInfo);
		    	}
				NavigateToNextPage();				
			}
        }
I'm not sure if maybe the ContainsImage() method or the Report.Log() method are creating all these back up images. I've tried to add a finally condition to delete the screenshot backup if the validation is successful but I could never quite get the location of the backup screenshots.

Thanks again for any help,

Kim

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: Controlling Screenshots Saved in Reports Folder

Post by qwertzu » Fri Mar 03, 2017 2:55 pm

Hi,

Unfortunately, it seems like there is no such method to use in UserCode.
But on default, a simple image validation should only save screenshots if the test fails.
If you use the Report.Screenshot(...) method, every image will be stored in you Reports folder.