How take all items and compare with screenshot

Ask general questions here.
n1kemax
Posts: 8
Joined: Wed Mar 06, 2019 1:55 pm

How take all items and compare with screenshot

Post by n1kemax » Tue Jun 04, 2019 3:46 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5071
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How take all items and compare with screenshot

Post by odklizec » Tue Jun 04, 2019 5:53 pm

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?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

n1kemax
Posts: 8
Joined: Wed Mar 06, 2019 1:55 pm

Re: How take all items and compare with screenshot

Post by n1kemax » Tue Jun 04, 2019 8:32 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5071
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How take all items and compare with screenshot

Post by odklizec » Tue Jun 04, 2019 8:40 pm

Hi,

Sadly, neither of the screenshots you posted is visible. But it seems you already found what’s wrong?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

n1kemax
Posts: 8
Joined: Wed Mar 06, 2019 1:55 pm

Re: How take all items and compare with screenshot

Post by n1kemax » Tue Jun 04, 2019 8:56 pm

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...

n1kemax
Posts: 8
Joined: Wed Mar 06, 2019 1:55 pm

Re: How take all items and compare with screenshot

Post by n1kemax » Tue Jun 04, 2019 9:46 pm

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