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;
Problem Counting Objects
-
- Posts: 94
- Joined: Tue Jun 16, 2009 10:27 pm
Re: Problem Counting Objects
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
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Problem Counting Objects
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:
Tobias
Support Team
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
-
- Posts: 94
- Joined: Tue Jun 16, 2009 10:27 pm
Re: Problem Counting Objects
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;
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;