How can I select checkboxes within GridControl.

Ask general questions here.
User avatar
felixk91
Posts: 20
Joined: Wed Feb 10, 2016 11:16 pm

How can I select checkboxes within GridControl.

Post by felixk91 » Wed Apr 01, 2020 8:22 am

Hi everyone,

I got table where I have to select checkboxes:
GridControl.PNG
GridControl.PNG (12.71 KiB) Viewed 258 times
I can't find the way how can expand list, select check boxes and scroll down.
Can someone help, please.
I attached snapshot of GridControl.

Thanks,
Felix.
Attachments
TableGridControl.rxsnp
(461.52 KiB) Downloaded 6 times

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

Re: How can I select checkboxes within GridControl.

Post by odklizec » Wed Apr 01, 2020 2:33 pm

Hi,

Because the [+] buttons are not identifiable as standalone elements and image-based recognition is not pretty useful here too, you will have to expand them differently. Looking in snapshot, it seems that individual items could be expanded by double click and then you can validate the "expanded" state via AccessibleState attribute, which contains "Expanded/Collapsed" keyword.

This xpath should return all expandable/collapsible elements:
/form[@title~'Floor Layout']//element[@windowtext='Validations' and @controlid!=null()][@visible='true']//table[@accessiblename='GridControl']/row[@accessibledefaultAction='Double-click']
Then this xpath, should return all checkboxes for expanded element:
/form[@title~'Floor Layout']//element[@windowtext='Validations' and @controlid!=null()][@visible='true']//table[@accessiblename='GridControl']/row[@accessiblevalue~'Supporting element' and @accessibledefaultaction!='Double-click'][@visible='true']//checkbox
Where $nameofExpandableItem variable contains the label of expanded element.
And here is a basic code sample for expanding rows, but you will have to add some code for enumerating rows with checkboxes, belonging to each expanded row...
public void ExpandRowsAndCheckItems(RepoItemInfo listOfRowsInfo) // where listOfRowsInfo points to the repo element, with xpath returning list of all expandable rows
{
IList <Ranorex.Row> rowItemsList = listOfRowsInfo.CreateAdapters<Ranorex.Row>(false);
foreach (Ranorex.ListItem rowItem in rowItemsList)
{
if (rowItem.Element.GetAttributeValueText("AccessibleState").Contains("Collapsed"))
{
rowItem.DoubleClick();
if (rowItem.Element.GetAttributeValueText("AccessibleState").Contains("Expanded"))
{
// here you must enumareate all chekbox rows, belonging to expanded row
}
}
}
}
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

User avatar
felixk91
Posts: 20
Joined: Wed Feb 10, 2016 11:16 pm

Re: How can I select checkboxes within GridControl.

Post by felixk91 » Thu Apr 02, 2020 12:12 pm

Hi odklizec,

Thank you for reply and thank you for the way to resolve my issue.
I got strange situation here.
As soon as method gets to the line:

Code: Select all

IList<Ranorex.Row> rowItemsList = listOfRowsInfo.CreateAdapters<Ranorex.Row>();
It finishes the run without any error or exception.
Just a bit of history here. I am using this method within popup watcher to handle dialog that in case of disabled Yes button required to click No button and acknowledge validation warnings by checking checkboxes. The popup watcher is using call back method which includes checkboxes selecting method.
Here is the code for call back method:

Code: Select all

 public static void LayoutWarningAcknowledge(RepoItemInfo info, Element element=null)
 {
       	element = repo.LayoutValidationDialog.ButtonYes;
       	
       	Report.Log(ReportLevel.Info, "Popup Watcher", string.Format("'{0}' popped up.", info.FullName));
       	Report.Screenshot("Popup Watcher", repo.LayoutValidationDialog.Self, false);
       	 
       	if (!element.Enabled)
       	{
       		Report.Log(ReportLevel.Info, "Button " + element.GetAttributeValueText("text") + " is disabled");
       	 	Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'LayoutValidationDialog.ButtonNo' at CenterLeft.", 			repo.LayoutValidationDialog.ButtonNoInfo);
       	 	repo.LayoutValidationDialog.ButtonNo.Click();
       	 	Delay.Milliseconds(100);
        	 	
       	 	Report.Log(ReportLevel.Info, "User", "Acknowledge layout warnings.", repo.LayoutWindow.LayoutValidationTabArea.ValidationTableInfo);
				
		ExpandRowsAndCheckItems(repo.LayoutWindow.CollectionOfExpandableRowsINValidationAreaInfo);
       	}
       	else
       	{
       		element.As<Button>().Click();
       	}
}
Thanks,
Felix.

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

Re: How can I select checkboxes within GridControl.

Post by odklizec » Thu Apr 02, 2020 12:18 pm

Hi,

Well, all I can suggest is to disable popupwatcher and try it again? Just to see if popupwatcher is causing this problem or not. Then try to debug the code, line by line, and especially the failing line. Eventually, add the failing line to try catch blog and debug the potential exception in catch blog.
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

User avatar
felixk91
Posts: 20
Joined: Wed Feb 10, 2016 11:16 pm

Re: How can I select checkboxes within GridControl.

Post by felixk91 » Fri Apr 03, 2020 6:11 am

Hi odklizec,

I found why method was getting out. The RxPath that I provided (similar to what you gave example) to find set of rows gave too long search time (almost 4 minutes) that was much bigger then search timeout. So I just provided the full RxPath to the set of rows and now it takes only 3.6sec to find set of rows.

Thank you for help, you are star :) .

Thanks,
Felix.