Can't Check/Uncheck TreeItems through API or Spy tool

Bug reports.
alex.arseneau
Posts: 2
Joined: Wed Oct 01, 2014 4:06 pm

Can't Check/Uncheck TreeItems through API or Spy tool

Post by alex.arseneau » Wed Oct 01, 2014 4:45 pm

Hi, we are in the process of building out a custom automated testing system. We use Ranorex for our UI integration and I noticed that we can't check or uncheck TreeItems regardless of whether or not we try to check it programmatically using the API or manually through the Spy tool. When we attempt to check it we see an error saying "Property value is not valid. Setting attribute 'checked' failed on element '{TreeItem:Root}'."

You can't check the tree item by clicking it either because Ranorex clicks inside the text of the tree item and not on the check box, so there is no simple way to check a checkable treeitem.

At first I thought this might have something to do with the application we are trying to automate, so we tried using it on a system TreeView with checkboxes and we experienced the same issue. We tested this on the Folder Options treeview. You can get to it by opening the Control Panel, select "Appearance and Personalization", then select "Folder Options", then choose the "View" tab. The tree view is under the "Advanced settings" subheading)

I believe this is a bug because you can the checked state of a standard checkbox control using the "Checked" property.

We are using Ranorex 4.0.4.23593, .NET Runtime 4.0.30319.18444. I've attached a Ranorex Snapshot of both our test application and the Folder Options dialog in the "Snapshots.zip" file.
Attachments
Snapshots.zip
(3.32 MiB) Downloaded 109 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Can't Check/Uncheck TreeItems through API or Spy tool

Post by krstcs » Thu Oct 02, 2014 6:14 pm

4.0.4 is a VERY old version of Ranorex. You should upgrade to a newer version (5.1.3 is latest) and try again.

Old versions of Ranorex are not supported for very long, so you should stay up-to-date as much as possible.

Also, they continually fix bugs and staying up-to-date will ensure that you are getting those fixes.



As far as this particular issue, you could try clicking on a different location for that item. For example you could try Center-Left instead of Center, or try using specific coordinates so that the mouse will be directly over the checkbox.
Shortcuts usually aren't...

JToelstede
Posts: 55
Joined: Fri May 24, 2013 12:57 pm

Re: Can't Check/Uncheck TreeItems through API or Spy tool

Post by JToelstede » Thu Oct 09, 2014 7:04 am

Hi Alex,
i do not know if you still have this problem but I tried tor reproduce it by using your excample of the Folder Options treeview but I could not reproduce your problem. We have a TreeItem in our Java Application and I wrote a function which navigates through that treeview. It was created with Ranorex 4.1.5 but is still running with Ranorex 5.1.2 on Win 7.

According to your excample of the Folder Options treeview here is some code you could try:

Code: Select all

using System.Linq;
/// The System.Linq namespace is in the System.Core assembly (in System.Core.dll) which have to be added in Refferences

Code: Select all

        TestRepository repo = TestRepository.Instance;

        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;
            
            //Click on FolderOptions in the taskbar
            repo.Explorer.Ordneroptionen.Click("Center");
            
            // Expand the tree 'Files and Folders' if it is collapsed
            if(!repo.Ordneroptionen.Tree30120.DateienUndOrdner.Expanded)
            	repo.Ordneroptionen.Tree30120.DateienUndOrdner.Expand();
           
            
       		selectTreeItemByName("Immer Menüs anzeigen"); // TreeItem 'Always show menus' -- default: checked
       		selectTreeItemByName("Versteckte Dateien und Ordner"); // TreeItem 'Hidden files and folders'
       		selectTreeItemByName("Immer Menüs anzeigen");// TreeItem 'Always show menus' -- default: checked
       		repo.Ordneroptionen.Tree30120.DateienUndOrdner.CollapseAll();
       		
        }
        
        private void selectTreeItemByName(string name)
        {
        	int idxDynTreeItem;
        	int idxFirstVisibleElement;
        	int idxLastVisibleElement;
        	repo.dynTreeItemName = name;
        	
        	// If TreeItem is not vidible scroll up or down
        	if(!repo.Ordneroptionen.Tree30120.dynTreeItem.Visible)
        	{
        		while(!repo.Ordneroptionen.Tree30120.dynTreeItem.Visible)
        		{
        			idxDynTreeItem = repo.Ordneroptionen.Tree30120.dynTreeItem.Element.ChildIndex;
        			idxFirstVisibleElement = repo.Ordneroptionen.Tree30120.DateienUndOrdner.Children.First(e => e.Visible).Element.ChildIndex;
        			idxLastVisibleElement = repo.Ordneroptionen.Tree30120.DateienUndOrdner.Children.Last(e => e.Visible).Element.ChildIndex;
        			Report.Info(string.Format("idxDynTreeItem = {0}; idxFirstVisibleElement = {1}; idxLastVisibleElement={2}", idxDynTreeItem, idxFirstVisibleElement, idxLastVisibleElement));
        			if(idxDynTreeItem > idxFirstVisibleElement && idxDynTreeItem > idxLastVisibleElement)
        				Keyboard.Press("{Next}");
        			else
        				Keyboard.Press("{PageUp}");		
        		}
        	}
        		
        	
        	if(repo.Ordneroptionen.Tree30120.dynTreeItem.Children.Count==0)
       		{
       			if(repo.Ordneroptionen.Tree30120.dynTreeItem.Checked)
       			{
	       			Report.Info("Hurra it is checked. Let's uncheck it!");
	       			repo.Ordneroptionen.Tree30120.dynTreeItem.Click();
       			}
       			else
       			{
	       			Report.Info("F***, it is not selected!!! Let's check it!");       		
	       			repo.Ordneroptionen.Tree30120.dynTreeItem.Click(Location.CenterLeft);
       			}
       		} else
       		{
       			Report.Info("The given TreeItem has some childelements. Count = " + repo.Ordneroptionen.Tree30120.dynTreeItem.Children.Count);
       			if(!repo.Ordneroptionen.Tree30120.dynTreeItem.Expanded)
       				repo.Ordneroptionen.Tree30120.dynTreeItem.Expand();
       			
       			Report.Info(string.Format("Childs: '{0}'", string.Join("', '", new List<Unknown>(repo.Ordneroptionen.Tree30120.dynTreeItem.Children).ConvertAll(t => t.Element.GetAttributeValueText("Text").ToString()).ToArray())));        	
       		}
        }
Best regards and have fun
Joe