Page 1 of 1

Validation of screenshot on screen

Posted: Fri Feb 22, 2013 1:21 am
by bsing
Hi there,

Just wondering is it possible to verify in code whether a snapshot is currently being displayed on screen?

e.g something like

Code: Select all

Bitmap screenshot1 = Ranorex.Imaging.Load("Screenshot1.png");
if (screenshot1.visible)
Also how do I know what path to input into the Load method for where the snapshots are stored?

Thanks,

Brad.

Re: Validation of screenshot on screen

Posted: Fri Feb 22, 2013 2:55 pm
by hs.fk
Hi,
bsing wrote:Just wondering is it possible to verify in code whether a snapshot is currently being displayed on screen?
You can use 'Host.Local' as an element that contains everything for 'Imaging.Contains' or 'Validate.ContainsImage'.
using ( var img = Ranorex.Imaging.Load( @"D:\Unbenannt.PNG" ) )
        {
        bool containsImg = Ranorex.Imaging.Contains( Ranorex.Host.Local, img );
        Ranorex.Report.Info( "Image visible: " + containsImg );

        try
          {
          // creates report messages on success and failure
          Ranorex.Validate.ContainsImage( Host.Local, img, new Imaging.FindOptions() );
          }
        catch ( Ranorex.ValidationException )
          {
          // do something (or not)
          } 
        }

Re: Validation of screenshot on screen

Posted: Mon Feb 25, 2013 1:30 am
by bsing
Thankyou ... this is exactly what I was after.