Get all screenshots in repo

Class library usage, coding and language questions.
korrektesoftware.de
Posts: 5
Joined: Tue Jan 29, 2019 5:57 pm

Get all screenshots in repo

Post by korrektesoftware.de » Tue Jan 29, 2019 6:07 pm

Hi,

I can get all repoitems from a certain folder like this:

Code: Select all

 foreach (RepoItemInfo r in repo.somefolder.SelfInfo.Children) {...} 
and I can get the screenshot of an individual item like this:

Code: Select all

repo.somefolder.somebutton.GetScreenshot1()
My question: How can I get *all* the screenshots of repoelements in a certain folder?

Thanks in advance,
Uwe Schmidt

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

Re: Get all screenshots in repo

Post by odklizec » Wed Jan 30, 2019 8:33 am

Hi,

For example, this code should create a screenshot of each element in provided repo folder:

Code: Select all

foreach (RepoItemInfo r in repo.somefolder.SelfInfo.Children) 
	{
		var elementScreenshot = Ranorex.Imaging.CaptureImage(r.CreateAdapter<Ranorex.Unknown>(false));
	}
Of course, this will work only if all elements in provided folder are actually visible! Hope this helps?
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

korrektesoftware.de
Posts: 5
Joined: Tue Jan 29, 2019 5:57 pm

Re: Get all screenshots in repo

Post by korrektesoftware.de » Wed Jan 30, 2019 1:18 pm

Perfect, thanks!

korrektesoftware.de
Posts: 5
Joined: Tue Jan 29, 2019 5:57 pm

Re: Get all screenshots in repo

Post by korrektesoftware.de » Wed Jan 30, 2019 6:55 pm

Actually, to follow up on my question:

an Element in the repository can have many screenshots attached to it. By right-clicking a repo element you can
- 'Update screenshot' - that's a single screenshot. Your method seems to validate against this image.
- 'Add validation screenshot' - each time this adds a new screenshot, useful for visually validating different state of the repo element. Individually you can acces them by

Code: Select all

 .GetScreenshot1() 
(or whatever their name is). This was what I was refering to in my question, and of course it would be nice to programmatically check all of those screenshots a repo folder.


It seems though that your solution is sufficient, and if I need to validate different state, I can create multiple repo elements, one screenshot each, for each state I want to check.

I would also be curious exactly what

Code: Select all

 .CreateAdapter<Ranorex.Unknown>
does and why it would yield an image!? Would you be so kind and offer a hint on how that works? Thanks!

Uwe Schmidt

McTurtle
Posts: 259
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Get all screenshots in repo

Post by McTurtle » Fri Feb 01, 2019 2:55 pm

Hello Uwe,

CreateAdapter() returns an element, not an image. The element is then used as an argument off CaptureImage(), this does return an image.

Regards,
McTurtle

korrektesoftware.de
Posts: 5
Joined: Tue Jan 29, 2019 5:57 pm

Re: Get all screenshots in repo

Post by korrektesoftware.de » Wed Feb 06, 2019 5:54 pm

thanks.

korrektesoftware.de
Posts: 5
Joined: Tue Jan 29, 2019 5:57 pm

Re: Get all screenshots in repo

Post by korrektesoftware.de » Thu Feb 07, 2019 11:02 am

However, I'm still curious on how to programmatically get those other screenshots, please see attached images.

RepoItemInfo r = repo.folder.elementInfo;

r. ... now what?

McTurtle
Posts: 259
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Get all screenshots in repo

Post by McTurtle » Thu Feb 07, 2019 2:29 pm

Hi Uwe,

Now... GetScreenshot1() ;) Or "Get+whatever_your_name_of_screenshot()". I think that's the only way. If you are going to capture screenshots programmatically during runtime, then you can handle them in code separately. If you already have them saved in the repository and you are building code based on them, then you anyway know what they are called. I did spend some time trying to figure this out myself a few months ago, and that was my conclusion :)

Regards,
McTurtle