Assign Repository Itmes to List<T>

Best practices, code snippets for common functionality, examples, and guidelines.
Utrehd
Posts: 4
Joined: Tue Nov 08, 2016 10:06 am

Assign Repository Itmes to List<T>

Post by Utrehd » Tue Nov 08, 2016 10:19 am

Hello

I would like to Create a List of buttons

Code: Select all

List<Ranorex.Button> buttons = new List<Ranorex.Button>();
and assign some repository items to it.

Code: Select all

buttons.Add(MyRepro.MainControl.SomeButton);

Now what happens is that before Ranorex adds this item into the list it will search on the screen for it. This i do not want, because sometimes the Items are not visible and it takes unnecessary time.

How can i Add an Repo item into a list without searching for it on the screen ?


Later i want to be able to use following code:

Code: Select all

foreach(var button in buttons)
{
	if(button.Visible == true)
	{
       	     Ranorex.Report.Success("Was found");
	}
}
Thanks
Sam

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

Re: Assign Repository Itmes to List<T>

Post by odklizec » Wed Nov 09, 2016 10:15 am

Hi Sam

I think your problem could be solved by using repo item "Info" object, as shown in this sample:
http://www.ranorex.com/support/user-gui ... html#c3574
The advantage of the "Info" object is that it access the element attributes without directly accessing the UI element. So it does not throw an exception if the element is not found and you can define the timeout how long the element should be searched for.
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