Page 1 of 1

How take all items and compare with screenshot

Posted: Tue Jun 04, 2019 3:46 pm
by n1kemax
Hi,

I have a window in which there is a list of pictures and I need to compare them all with screenshot
Image

I'm trying to do it, but it doesn't work:

Code: Select all

public void ValidateCompareImages()
        {
        	try
        	{
        		IList<Ranorex.Picture> imagesList = Myrepo.ModalWindows.MyWindow.Find<Ranorex.Picture>;
        	
        		foreach (Ranorex.Picture imageItem in imagesList)
        		{
        			Validate.CompareImage(repo.ModalWindows.MyWindow.ImageInfo, Image_Screenshot1, Image_Screenshot1_Options);
        		}
        	}
        	catch (Exception ex)
        	{
        		throw new InvalidOperationException("Failed to compare images: " + ex.Message);
        	}
Cheers,
Stanislav

Re: How take all items and compare with screenshot

Posted: Tue Jun 04, 2019 5:53 pm
by odklizec
Hi,

At first, could you please post a Ranorex snapshot (NOT screenshot) of the window, containing the images? A screenshot/example of ref. image would be helpful too.

Also, please show us the xpath behind the window (as stored in repository).

And finally, what exactly is not working? Is there an error message you are getting?

Re: How take all items and compare with screenshot

Posted: Tue Jun 04, 2019 8:32 pm
by n1kemax
Hi Odklizec,

Thanks for your quick replay.
At first, could you please post a Ranorex snapshot (NOT screenshot) of the window, containing the images? A screenshot/example of ref. image would be helpful too.
I can't post snapshot because of security police.
I will add screenshot and screenshot images, I hope this helps
Image
Image
Also, please show us the xpath behind the window (as stored in repository).

Code: Select all

/form[@name~'^My\ app\ ']//picture[]
And finally, what exactly is not working? Is there an error message you are getting?
different mistakes :lol: I know what i'm doing wrong

Cheers,
Stanislav

Re: How take all items and compare with screenshot

Posted: Tue Jun 04, 2019 8:40 pm
by odklizec
Hi,

Sadly, neither of the screenshots you posted is visible. But it seems you already found what’s wrong?

Re: How take all items and compare with screenshot

Posted: Tue Jun 04, 2019 8:56 pm
by n1kemax
odklizec wrote:
Tue Jun 04, 2019 8:40 pm
Hi,

Sadly, neither of the screenshots you posted is visible.
Strange... I see screenshots...
But it seems you already found what’s wrong?
No, I'm still looking for a solution...

Re: How take all items and compare with screenshot

Posted: Tue Jun 04, 2019 9:46 pm
by n1kemax
odklizec wrote:
Tue Jun 04, 2019 8:40 pm
But it seems you already found what’s wrong?
I'm not sure about the correctness but it works :

Code: Select all

public void ValidateCompareImages()
        {
        	try
        	{
        		IList<Ranorex.Picture> imagesList = repo.ModalWindows.ConditionsWindow.ImageInfo.CreateAdapters<Ranorex.Picture>();
        		
        		foreach (Ranorex.Picture imageItem in imagesList)
        		{
        			Report.Log(ReportLevel.Info, "Validation", "la-la-la", repo.ModalWindows.ConditionsWindow.ImageInfo, new RecordItemIndex(0));
        			Validate.CompareImage(imageItem, Image_Screenshot1, Image_Screenshot1_Options);
        			Delay.Milliseconds(0);
        		}
        	}
        	catch (Exception ex)
        	{
        		throw new InvalidOperationException("Failed to compare images: " + ex.Message);
        	}
        }
Cheers,
Stanislav