Validate State of all checkbox items in TreeView Control

Best practices, code snippets for common functionality, examples, and guidelines.
chentiangemalc
Posts: 1
Joined: Tue Dec 23, 2014 4:34 am

Validate State of all checkbox items in TreeView Control

Post by chentiangemalc » Tue Dec 23, 2014 4:40 am

1) Is this possible with a recording, or has to be scripted?
2) For an example of the type of control - Internet Explorer -> Internet Options -> Advanced Tab.

Let's say we have this TreeView and all its TreeItem set with correct checkbox status, I was able to capture this, and save it in repository.

Can I use that now to compare the checked value, against the saved one.

Something like this, but I want to validate all items, not just one:

Validate.Attribute(repo.Iexplore1.Tree14391.AllowActiveContentFromCDsToRunOnInfo, "Checked", "True");

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Validate State of all checkbox items in TreeView Control

Post by Support Team » Tue Dec 23, 2014 3:35 pm

Hello chentiangemalc,

It's not possible to test multiple elements within one validation action. In order to do so, you could use following code:
Tree tree = "pathToTreeElement";

			var treeSections = tree.FindDescendants<TreeItem>();
			
			foreach(var section in treeSections)
			{
				var checkBoxes = section.FindDescendants<TreeItem>();

				foreach(var checkBox in checkBoxes)
				{
					string message = String.Format("Validating {0}", checkBox.Text);
					Validate.Attribute(checkBox, "Checked", "True", message,false);
				}
			}
Hope this information helps.

Regards,
Robert
.
Image