Problem Counting Objects

Ask general questions here.
costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Problem Counting Objects

Post by costamesakid » Thu Dec 09, 2010 10:54 pm

Hello,

Im using the follwing code to count how many pictures are displayed on my screen. What I need to do is not only get the count of how many pictures but rather get the count of how many pictures with a certain accessiblevalue. In this case accessiblevalue='Track'. Any ideas on how I can go about doing this?


Ranorex.Container cont1 = repo.FormTacViewC2.ContainerRvView;
IList<Picture> list1 = cont1.FindDescendants<Picture>();
TCount = list1.Count;

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Problem Counting Objects

Post by costamesakid » Fri Dec 10, 2010 5:47 am

Actually, I have a repo item with the accessiblevalue in the RxPath, so all I really need is a way to count the the number of this repo item exists, or is visible. Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Problem Counting Objects

Post by Support Team » Fri Dec 10, 2010 11:29 am

Hi,

you can get the count of the controls which have some attribute set to a specific value by using the RanoreXPath to specify which element you want to examine. You can get a list of those controls using the find method. After that you can print out the count of your list.

E.g. if you hav a webpage and want do print out the count of "A-Tags" where the attribute anabled is set to True you can use following code:
BodyTag body = "/dom[@browsername='IE']/body";
IList<ATag> a_tags = body.Find<ATag>(".//a[@enabled='True']");
Report.Info("Info: ", a_tags.Count.ToString());
Regards,
Tobias
Support Team

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Problem Counting Objects

Post by costamesakid » Fri Dec 10, 2010 5:09 pm

Thanks

Our application is not web based but i was able to use RxPath with the Find method to get a count of all repo items of that RxPath in my container.

Ranorex.Container cont1 = repo.FormTacViewC2.ContainerRvView;
IList<Picture> list1 = cont1.Find<Picture>(@"/form[@title~'^TacViewC2\ \ \ \(map:\ .*']/element/container/picture[@accessiblevalue='Track']");
TCount = list1.Count;