Page 1 of 1

Validate State of all checkbox items in TreeView Control

Posted: Tue Dec 23, 2014 4:40 am
by chentiangemalc
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");

Re: Validate State of all checkbox items in TreeView Control

Posted: Tue Dec 23, 2014 3:35 pm
by Support Team
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