How to retrieve list items text and then compare it

Ask general questions here.
alpesh.dhakad
Posts: 30
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.
Attachments
ListItems -Spy Image.PNG
Listitems in Spy
ListItems -Spy Image.PNG (81.66 KiB) Viewed 73 times
Dropdown Listitems2.PNG
Dropdown list UI
Dropdown Listitems2.PNG (50.89 KiB) Viewed 73 times
Dropdown Listitems.PNG
Listitems after clicking dropdown
Dropdown Listitems.PNG (103.37 KiB) Viewed 73 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6544
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: 30
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
Attachments
det_Snapshot.rxsnp
Snapshots
(151.05 KiB) Downloaded 4 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6544
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
DeletePost.png (47.76 KiB) Viewed 62 times
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: 30
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.
Attachments
Delete.PNG
Delete.PNG (75.75 KiB) Viewed 56 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6544
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