How to retrieve attribute value from Dynamic in listitem

Best practices, code snippets for common functionality, examples, and guidelines.
JillNarra
Posts: 3
Joined: Thu Aug 15, 2019 3:52 pm

How to retrieve attribute value from Dynamic in listitem

Post by JillNarra » Thu Aug 15, 2019 4:16 pm

Hi,

I need your help on how to retrieve the text from "c" attribute from a listItem. I have the following implementation below. However, I am receiving an exception that it object is not set to an instance of an object.
Ranorex spy.JPG
List.JPG
implementation.JPG
Thank you so much for the help.
You do not have the required permissions to view the files attached to this post.

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: How to retrieve attribute value from Dynamic in listitem

Post by qwertzu » Fri Aug 16, 2019 9:10 am

Hi Jill,

First of all, you will need a different path, that points to all of your list items.
In your case, this would be possible by adding "/listitem" at the end of your path of your "MoveletList" element.
So, the path should end with //list@type='na']/listitem
This will be a path to all of the list items.

Afterwards, you need to adapt your code a little bit.

Use the following:

Code: Select all


IList<Ranorex.ListItem> list = repo.Movilizer.ContainerHv.MoveletListInfo.CreateAdapters<Ranorex.ListItem>();

foreach (Ranorex.ListItem item in list) {
        		
        		string moveletCategory = item.Element.GetAttributeValueText("c");
        		...
        		...
        	}

This should work.

regards, qwertzu

JillNarra
Posts: 3
Joined: Thu Aug 15, 2019 3:52 pm

Re: How to retrieve attribute value from Dynamic in listitem

Post by JillNarra » Fri Aug 16, 2019 1:57 pm

Hi qwertzu,

It actually works! Thank you!