Update repository images within tests ?

Ask general questions here.
StephenMag
Posts: 2
Joined: Tue Mar 04, 2014 4:11 pm

Update repository images within tests ?

Post by StephenMag » Tue Apr 22, 2014 2:13 pm

Hey there,

One of our software packages is imaging based software, in that it allows us to take acquisitions from our cameras and analysis it etc

Im trying to create a test that ensures that while the Camera is in "Video mode" the image is constantly updating. In theory how I would like to do this test is to run for 2 or 3 minutes while in video mode, and every 5-10 seconds to take a screenshot and compare it to the previous one. Is it possible to use Ranorex's image based testing in this way ? Or are there any plans to implement such a feature ? It would be something that would help our testing team greatly.

Thanks

Stephen

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Update repository images within tests ?

Post by mzperix » Thu Apr 24, 2014 8:46 am

Hi Stephen,

I am not sure about using the image based validation in Ranorex studio is able to do what you need, but you can do this in code with the help of Imaging class: http://www.ranorex.com/Documentation/Ra ... maging.htm

You can make screenshots of elements, and also compare them.

Regards,
Zoltan

dhh
Posts: 2
Joined: Thu Apr 24, 2014 1:40 pm

Re: Update repository images within tests ?

Post by dhh » Thu Apr 24, 2014 1:49 pm

I've done something similar using this usercode:

Code: Select all

using System.Drawing;

public void IsClipPlaying()
        {
        	   	
			//Graphical confirmation of Video Playing
															
				//Capture a bitmap
					Thread.Sleep(50); //give the clip a chance to load
					Bitmap imgA = Imaging.CaptureImage(repo.xxx.VideoWindow); //take a screenshot
					Report.Screenshot(repo.xxx.VideoWindow); 
					
					double Similarity = 1; // set the Similarity to 1 which means images are identical
				
				//if they are the same (indicating there is possible problem with the recording)
					int RetryCount = 0;
					while (Similarity > 0.998) //while frames look the same (problematic) attempt retries (screen comparisons)
					{
						if (RetryCount == 99)
						{					
							break; //quit this while loop after 100 (0-99) match attempts
						}
						
						Report.Info("Comparing screenshots" + ",retry: " + RetryCount.ToString());	
						
						Thread.Sleep(25); //wait before taking another screenshot
						Bitmap imgRetry = Imaging.CaptureImage(repo.xxx.VideoWindow);
						
						Similarity = 1;
						Similarity = Imaging.Compare(imgA,imgRetry);
						RetryCount = RetryCount + 1;						
					}
					//show the last video grab
					Report.Screenshot(repo.xxx.VideoWindow);
					
					//Validate that the images were different
					Validate.IsTrue(Similarity < 0.998,"Does Video show movement?",false);						
			}           
    }

StephenMag
Posts: 2
Joined: Tue Mar 04, 2014 4:11 pm

Re: Update repository images within tests ?

Post by StephenMag » Thu Apr 24, 2014 4:37 pm

Yeah, I figured it out using the Imaging class, was exactly what I needed.

Thanks