How to retrieve list items text and then compare it

Ask general questions here.
alpesh.dhakad
Posts: 35
Joined: Wed Oct 31, 2018 2:10 pm

How to retrieve list items text and then compare it

Post by alpesh.dhakad » Thu Apr 29, 2021 7:59 am

Hi Team,
I am using desktop application and there are lot of Listitems in which Text value is available which I want to collect in some list.
So, could you please suggest a solution to collect the listitems text in some list or any other way which I can compare later with test data.
Some of the listitems are empty which doesn't contain any text. (May be those listitems are hidden)

I have tried below solution but not able to get any value

IList<Ranorex.ListItem> list = repo.AddDevices.AllDevicesContainerInfo.CreateAdapters<Ranorex.ListItem>();

string deviceList = item.Element.GetAttributeValueText("text");
foreach (Ranorex.ListItem item in list) {

string deviceList = item.Element.GetAttributeValueText("text");
Report.Info(item.Text + " is member of CategoryList");

}

In the screenshot attached, I am able to click on Detectors dropdown using below xpath but not able to retrieve the list under that:
progressbar/container[@automationid='PART_AutoHideControl']//button/list/listitem[@actualcaption='801 CH']/ancestor::container[@automationid='PART_ItemsPresenter']//container[@automationid='PART_DropDown']

Please refer attached screenshots for UI and SPY (listitems) and snapshots.
You do not have the required permissions to view the files attached to this post.

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

Re: How to retrieve list items text and then compare it

Post by odklizec » Thu Apr 29, 2021 8:02 am

Hi,

Please post a Ranorex snapshot (NOT screenshots). This would help us understand the GUI. Screenshots are, more or less, useless here ;) Thanks.

Anyway, on the first sight, I see you are trying to collect ListItems, but the the text you are looking for is actually stored in "Text" element! So the xpath of repoitem repo.AddDevices.AllDevicesContainerInfo must point to the Text element, instead of ListItem, like this...

Code: Select all

/contextmenu[@Visibility='Visible']/list/ListItem/Text
And of course, you must adapt the code accordingly.

Code: Select all

IList<Ranorex.Text> list = repo.AddDevices.AllDevicesContainerInfo.CreateAdapters<Ranorex.Text>();
Please move the snapshot you posted in duplicated post to this one instead and delete the duplicated post. Thanks.
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

alpesh.dhakad
Posts: 35
Joined: Wed Oct 31, 2018 2:10 pm

Re: How to retrieve list items text and then compare it

Post by alpesh.dhakad » Thu Apr 29, 2021 8:37 am

Hi,
Please refer attached snapshot. Let me know anything else I need to share.
Thanks
You do not have the required permissions to view the files attached to this post.

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

Re: How to retrieve list items text and then compare it

Post by odklizec » Thu Apr 29, 2021 8:47 am

Hi,

So now try to implement changes I mentioned in my answer ;) And please delete the duplicated post by clicking Delete button...
DeletePost.png
You do not have the required permissions to view the files attached to this post.
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

alpesh.dhakad
Posts: 35
Joined: Wed Oct 31, 2018 2:10 pm

Re: How to retrieve list items text and then compare it

Post by alpesh.dhakad » Thu Apr 29, 2021 10:06 am

Hi ,

I am not able to view delete option in my post. So, unable to delete that post.
You do not have the required permissions to view the files attached to this post.

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

Re: How to retrieve list items text and then compare it

Post by odklizec » Thu Apr 29, 2021 10:31 am

Ho, try it now. I just deleted my post, which was maybe a reason why you could not delete the post.
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

alpesh.dhakad
Posts: 35
Joined: Wed Oct 31, 2018 2:10 pm

Re: How to retrieve list items text and then compare it

Post by alpesh.dhakad » Thu May 20, 2021 3:21 pm

Thanks. Your suggested solution worked.
I have also deleted duplicate entry.