Validation of screenshot on screen

Class library usage, coding and language questions.
bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Validation of screenshot on screen

Post by bsing » Fri Feb 22, 2013 1:21 am

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.

hs.fk
Posts: 12
Joined: Thu Jul 12, 2012 11:47 am
Location: Hamburg

Re: Validation of screenshot on screen

Post by hs.fk » Fri Feb 22, 2013 2:55 pm

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)
          } 
        }

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: Validation of screenshot on screen

Post by bsing » Mon Feb 25, 2013 1:30 am

Thankyou ... this is exactly what I was after.