This project is read-only.

Handling a custom control in CUITE

Sep 26, 2012 at 10:07 PM


I have the following HTML:

<li class="jstree-closed">
<ins class="jstree-icon"> </ins>
<a href="#">
<ins class="jstree-icon"> </ins>


I am using the innertext = DSL to get the link however I need to click the Sibling (ins).  I tried this code however I am getting a error:

 string searchParam = "InnerText="

+ serviceName;

 CUITe_HtmlHyperlink selectAServiceLink = Get<CUITe_HtmlHyperlink



CUITe_HtmlListItem myThing = (CUITe_HtmlListItem)SelectAServiceLink.PreviousSibling;


Anyone have a better way to get at the <ins/>? 

 As a side note I think that error is occurring in the CUITe_HTMLControl.  There are a series of If statements that try to determine the type of the sibling.  In this case it is custom however then the code tries to assign a type based on the tag.  ins is not listed so the control stays null.  I think that these if need a final else that says if the tag is not found then throw an error/ return a null.  Not sure of what should happen.





Sep 27, 2012 at 8:36 AM

Hi Jeff,

What is the error message and stack trace?

You are right about the problem in CUITe_HTMLControl and I'm thinking we need to implement CUITe_HtmlCustom and add an else condition as follows:

     _con = new CUITe_HtmlCustom(control.TagName);

Sep 27, 2012 at 4:07 PM


Thanks for the response and the code sample.  The error message and stack trace are not much help.  Here they are:

Test method CUITE_SalesCentral.CodedUITest1.ServiceSelectPage threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.

CUITe.Controls.HtmlControls.CUITe_HtmlControl`1.WrapUtil(HtmlControl control) in C:\CUITe\CUITe\Controls\HtmlControls\CUITe_HtmlControl.cs: line 309
CUITe.Controls.HtmlControls.CUITe_HtmlControl`1.get_PreviousSibling() in C:\CUITe\CUITe\Controls\HtmlControls\CUITe_HtmlControl.cs: line 112
CUITE_SalesCentral.ObjectRepository.SelectService.SelectAServiceFromTree(String serviceName) in C:\TestAutomation\CUITE_SalesCentral\CUITE_SalesCentral\ObjectRepository\SelectService.cs: line 32
CUITE_SalesCentral.CodedUITest1.ServiceSelectPage() in C:\TestAutomation\CUITE_SalesCentral\CUITE_SalesCentral\CodedUITest1.cs: line 109

I'll try your code update in my iinstance of CUITe and let you know how things go.


Sep 27, 2012 at 6:47 PM

So I implemented the CUITe_HTMLCustom.cs and added the else to the CUITe_HTMLControl (code for the HTMLCustom class is below) but now I am getting a message that another control is blocking the click.  I am able to highlight the control.  Has anyone seem this sort of behavior before?  Any idea how to get around it? Here is the error message:

Test method CUITE_SalesCentral.CodedUITest1.ServiceSelectPage threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control. Please make the blocked control visible and retry the action. Additional Details:
TechnologyName:  'Web'
ControlType:  'Custom'
Id:  ''
Name:  ''
TagName:  'INS'
 ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0xF004F003

Stack Trace:

Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.MouseButtonClick(Int32 x, Int32 y, Int32 nButton, Int32 fEnsureVisible, String bstrKeyModifiers)
Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.MouseButtonClick(Int32 x, Int32 y, MouseButtons button, ModifierKeys modifierKeys, Int32 ensureVisible)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Click(MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinates)
Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, UITestControl uiControl, Point point)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Click(MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinates)
Microsoft.VisualStudio.TestTools.UITesting.Mouse.ClickImplementation(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
Microsoft.VisualStudio.TestTools.UITesting.Mouse.ClickImplementationWrapper(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl control)
CUITe.Controls.CUITe_ControlBase`1.Click() in C:\CUITe\CUITe\Controls\CUITe_ControlBase.cs: line 144
CUITE_SalesCentral.ObjectRepository.SelectService.SelectAServiceFromTree(String serviceName) in C:\TestAutomation\CUITE_SalesCentral\CUITE_SalesCentral\ObjectRepository\SelectService.cs: line 37
CUITE_SalesCentral.CodedUITest1.ServiceSelectPage() in C:\TestAutomation\CUITE_SalesCentral\CUITE_SalesCentral\CodedUITest1.cs: line 112

CUITe_HtmlCustom Code:

using System;


using System.Collections.Generic;


using System.Linq;


using System.Text;

using Microsoft.VisualStudio.TestTools.UITesting;

using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;

namespace CUITe.Controls.HtmlControls


 public CUITe_HtmlCustom() : base

() { }

 public CUITe_HtmlCustom(string sSearchParameters) : base

(sSearchParameters) { }

 public void













 public class CUITe_HtmlCustom : CUITe_HtmlControl<HtmlCustom


Sep 27, 2012 at 7:10 PM

Hi Jeff,

I recommend turning on tracing for coded UI test components for additional diagnostic information.

How To: Enable Tracing for “UI Test” Components

Sep 27, 2012 at 9:56 PM


Thanks for the tip.  I added the debug settings and I'm slowly going through the giant log that it generated.  I'll post the results tomorrow.  In the mean time I remembers the CUITe_ObjectRecorder and decided to see what it would produce for these controls.  When I click on the control in question nothing is recorded.  That probably doesn't bode well for being able to select the item using CUITe huh?  It seems to record all of the other objects on the page.

This control is an expandable tree control that has a list within a list.  The thing that I am trying to click is an icon <ins/> that expands one of the items in the tree.

Thanks again,


Sep 28, 2012 at 8:30 AM

Hi Jeff,

I've checked in a more proper implementation of the CUITe_HtmlCustom class and also implemented CUITe_HtmlIns.

Please try the changeset 20438 and the following code:

CUITe_HtmlHyperlink selectAServiceLink = Get<CUITe_HtmlHyperlink>(searchParam);

CUITe_HtmlIns myThing = selectAServiceLink.Get<CUITe_HtmlIns>()


Thank you.

Sep 28, 2012 at 4:26 PM


Thanks for making this update.  I built the updates to the solution and implemented the code that you included in the post but I still ran into the blocking message.  I was finally able to overcome the problem though, with a less than ideal solution, but one that works for now.  I am getting the parent and then using the parent control to move the mouse.  This places my cursor in the top left-hand part of the control which is close enough, if I do a click at this point, to expand the tree.  Here is the code that I am using:

            //Get the element based on the name of the service
            string searchParam = "InnerText=" + serviceName;
            CUITe_HtmlHyperlink selectAServiceLink = Get<CUITe_HtmlHyperlink>(searchParam);
            //Get the parent on the control that contains the text I searched for
            CUITe_HtmlListItem myParent = (CUITe_HtmlListItem) selectAServiceLink.Parent;
            //Unwrap this control so it is a UITestControl rather than a CUITe control
            UITestControl uiMyParent = myParent.UnWrap();
            //Set-up a point and then move the mouse to that point relative to the parent control
            System.Drawing.Point myPoint = new System.Drawing.Point(0,0);
            Mouse.Move(uiMyParent, myPoint);
            //click at this point to expand the grid
I still want to resove the blocking issue but at this point I am out of ideas.  I still need to go through the huge stack trace 
that I generated yesterday to see if that has any clues.
Thanks again for the help.