Unable to retrive Checked property of listitem

Ask general questions here.
rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Unable to retrive Checked property of listitem

Post by rsudhak » Mon Dec 02, 2019 5:15 pm

Hi ,
I want to retrieve the checked property of a list item, looks like this property is dynamic, as when I use spy I am not able to see this property, but when I Cntrl + Win then I do see this.
each list item has a checkbox associated with it, but can't differentiate it. Since I cant see the seperation of checkbox and listitem , my click item also doesnt work, I have to use keyboard press space, but at present cant figure out whether an item is checked or not.
Any help.
I have attached the screenshot for reference

My code
private void HandleFiltersToDeselect(string filter) {
Ranorex.ComboBox combo = Repo.SharedParameters_ParameterProperties.ProjectParameters.Combobox_Category_FilterList;
combo.Click();
ListItem item = combo.FindSingle<ListItem>("//listitem[@text='"+filter+"']");
if(item.Element.GetAttributeValue<bool>("Checked")) {
item.Focus();
Keyboard.Press(Keys.Space);
}
Repo.SharedParameters_ParameterProperties.ProjectParameters.Label_FilterList.Click();


Thanks in advance

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

Re: Unable to retrive Checked property of listitem

Post by odklizec » Mon Dec 02, 2019 5:39 pm

Hi,

I’m afraid, you forgot to attach the snapshot (do not attach the screenshot, which is unfortunately useless).
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

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: Unable to retrive Checked property of listitem

Post by rsudhak » Tue Dec 03, 2019 9:21 am

Sorry about that
List '1000' is the dynamic list that appears on Cntrl + Win, cant take a snapshot of it as it says, it no longer valid
Attachments
Listitem 2.png
Listitem 2.png (4.52 KiB) Viewed 67 times
Listitem 1.png
Listitem 1.png (18.56 KiB) Viewed 67 times
Combobox.rxsnp
(49.55 KiB) Downloaded 2 times

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

Re: Unable to retrive Checked property of listitem

Post by odklizec » Tue Dec 03, 2019 9:25 am

Hi,

Then create the snapshot using Recording module Create Snapshot action. Simply add Create Snapshot action, right after the action, which makes it visible. Then run either the recording alone or entire test suite. This should do the trick. 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

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: Unable to retrive Checked property of listitem

Post by rsudhak » Tue Dec 03, 2019 10:48 am

Created , but not sure where did it get saved...
Attachments
MyTest1.7z
(394.99 KiB) Downloaded 2 times

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

Re: Unable to retrive Checked property of listitem

Post by odklizec » Tue Dec 03, 2019 11:07 am

You must run the the project and then there should be created a link to snapshot in Report file. The snapshot alone should be created in bin\debug|release\reports folder.
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

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: Unable to retrive Checked property of listitem

Post by rsudhak » Tue Dec 03, 2019 11:35 am

here it is
Attachments
snapshot.rxsnp
(9.29 KiB) Downloaded 2 times

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

Re: Unable to retrive Checked property of listitem

Post by odklizec » Tue Dec 03, 2019 12:10 pm

Thanks. Now what exactly is your goal? Get the list of all checked items and uncheck them? Or get the list of all unchecked items and check them?

Basically, you can get the list of all list items and do whatever you want with checked or unchecked list items, with this code:

Code: Select all

private void HandleFiltersToDeselect(RepoItemInfo listItemsInfo) 
{
    IList<Ranorex.ListItem> listItems = listItemsInfo.CreateAdapters<Ranorex.ListItem>();
    foreach (Ranorex.ListItem item in listItems)
    {
        if (item.Element.GetAttributeValue<bool>("Checked"))
      	{
      	    Report.Info("List Item: " + item.Element.GetAttributeValueText("Text").ToString());
      	    item.Focus();
            Keyboard.Press(Keys.Space);
      	}
    }
}
Where listItemsInfo repo info element should use xpath like this:

Code: Select all

/list[@processName='Revit' and class='ComboLBox'][@visible='true']/listitem
Hope this helps? ;)
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

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: Unable to retrive Checked property of listitem

Post by rsudhak » Tue Dec 03, 2019 1:24 pm

I am unable to use this, as I get this error
The non-generic method 'Ranorex.Core.Element.GetAttributeValue(string)' cannot be used with type arguments (CS0308) - C:\Repository\DesignSuite\cablerouting\Ranorex\CableRouting\CableRouting\Revit.Common\Helpers\ProjectParameters.cs:156,22

Tried using GetAttributeValueText, but still same issue

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

Re: Unable to retrive Checked property of listitem

Post by odklizec » Tue Dec 03, 2019 3:03 pm

Hi,

Does it fail at this line?...

Code: Select all

if (item.Element.GetAttributeValue<bool>("Checked"))
In this case, use this instead...

Code: Select all

if (item.Element.GetAttributeValueText("Checked")="True")
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

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: Unable to retrive Checked property of listitem

Post by rsudhak » Wed Dec 04, 2019 9:55 am

Have clicked on the Combobox and trying to select all, but no luck, it doesn't focus on the items at all, neither does the pressing space works

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

Re: Unable to retrive Checked property of listitem

Post by odklizec » Wed Dec 04, 2019 10:11 am

Hi,

Unfortunately, its hard to tell what's wrong without seeing your app.

Have you debugged the code? Is the iList filled with correct list elements?
Also, have you tried to click each item, instead of using focus and keyboard action? Simply add item.Click(); method, eventually, item.Move(); and item.Click();
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