Not able to find List items text value

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

Not able to find List items text value

Post by alpesh.dhakad » Fri Nov 02, 2018 3:57 pm

Hi ,

I am using Desktop application and I need to retrieve text from ListItems present in List .
I have written below code and i could not find text values. When I try to debug it is showing "null" for S and for dropDownListText showing Timeout. Though in count it is having 4.

Please refer attached screenshot.

Please suggest solution for the same. I am stuck from so many days

repo.applicationName.PARTItemsPresenter.cell_DeviceSensitivity.Click();
repo.applicationName.PARTItemsPresenter.PARTItem.Click();
repo.applicationName.PARTItemsPresenter.PARTItem.Click();

IList<Ranorex.ListItem> dropDownListText = repo.ContextMenu.PARTContent.Items;
foreach (Ranorex.ListItem element in dropDownListText)
{
ListItem s = repo.ContextMenu.PARTContent.Items.ElementAt(0);
Report.Log(ReportLevel.Success,s.Text);
}
if (repo.ContextMenu.PARTContent.Items.Count > 0)
{
Report.Log(ReportLevel.Success,"Success ");
}
else
{
Report.Log(ReportLevel.Failure,"Failed");
}
}
Attachments
List items.png
List items.png (91.32 KiB) Viewed 38 times

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

Re: Not able to find List items text value

Post by odklizec » Mon Nov 05, 2018 9:22 am

Hi,

In my opinion, your code tries to read the "Text" attribute from wrong Text repo element (always first one) and not the Text element, associated with the actually looped ListItem? Please upload a Ranorex snapshot (NOT screenshot) of the problematic list. Screenshots are not useful here. 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