Is it possible to have a list of similar web elements.

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
User avatar
FelixK98
Posts: 54
Joined: Fri Apr 08, 2016 6:28 am

Is it possible to have a list of similar web elements.

Post by FelixK98 » Thu Sep 01, 2016 3:10 am

Hi Everyone,

I got web page which contains a few objects with the same RxPath;

Code: Select all

/dom[@caption~'XXXXX']//formtag[@name='defineLabelFormat.labelFormatForm']//label[@innertext='Variable']
The number of these elements on the web page is dynamic. For example it can be 3 and it can be 7 elements on page.
When I put this RxPath within Spy it returns to me with 3 or 7 elements that got recognized:
Spy_screen_3_elements.PNG
So, my question is it possible to make list of these elements programmatically during test run.
How should it looks like? Is it an array of elements? Can I use somehow IList<T> to create list like this one?

Thanks,
Felix.
You do not have the required permissions to view the files attached to this post.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Is it possible to have a list of similar web elements.

Post by krstcs » Thu Sep 01, 2016 1:22 pm

You can use Find<T>("<child rxpath>") from the parent repo element. It returns an IList<T> which can be used in a foreach loop to get each element, if needed.
Shortcuts usually aren't...

User avatar
FelixK98
Posts: 54
Joined: Fri Apr 08, 2016 6:28 am

Re: Is it possible to have a list of similar web elements.

Post by FelixK98 » Fri Sep 02, 2016 2:52 am

Hi krstcs,

Could you please provide some example code?

Thanks,
Felix.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Is it possible to have a list of similar web elements.

Post by krstcs » Fri Sep 02, 2016 3:15 pm

Since I don't work on your project, and I know only what little you have stated, I can't give you anything more than psuedo-code like below.

Code: Select all

foreach (Label label in repo.RootFolder.ParentFolder.Self.Find<Label>("<put your path here>") {
  // do stuff here
}
You can find information on the Ranorex .NET API here: http://www.ranorex.com/Documentation/Ranorex/
Shortcuts usually aren't...

User avatar
FelixK98
Posts: 54
Joined: Fri Apr 08, 2016 6:28 am

Re: Is it possible to have a list of similar web elements.

Post by FelixK98 » Mon Sep 05, 2016 12:40 am

Hi krstcs,

Thank you for example.
Looks like it works for me.

Thanks,
Felix.