This project is read-only.

Unable to find custom control

May 6, 2013 at 4:57 AM
HI Icnocop,

I am able to find a custom control by coded ui but not using cuite

in coded ui the following identifies the control without any issue
            HtmlCustom cus = new HtmlCustom(pgDataFeeds.divFeedTabs.UnWrap());
            cus.SearchProperties.Add(HtmlCustom.PropertyNames.TagName, "ul", PropertyExpressionOperator.EqualTo);
            cus.SearchProperties.Add(HtmlCustom.PropertyNames.Class, "dataFeedTab ui-tabs-nav", PropertyExpressionOperator.EqualTo);
but in the cuite same search properties doesn't identify the control.
        public CUITe_HtmlCustom cusDataFeedTabsNav = new CUITe_HtmlCustom("Class=dataFeedTab ui-tabs-nav;TagName=ul");
        public CUITe_HtmlCustom cusdatafeedtabsnav1
                return (this.divFeedTabs.Get<CUITe_HtmlCustom>("Class=dataFeedTab ui-tabs-nav;TagName=ul"));//;TagName=ul
any clue ?
May 6, 2013 at 6:25 AM
Hi deepakguna,

What is divFeedTabs?

Can you post the complete html and cuite code that can reproduce this issue?

(Or at least a complete sample)

Thank you.
May 6, 2013 at 7:43 AM
divFeedTabs is div
public CUITe_HtmlDiv divFeedTabs = new CUITe_HtmlDiv("Id=feed_tabs");
html looks like this
<div id="feed_tabs" class="ui-tabs">
                    <ul class="dataFeedTab ui-tabs-nav">

                        <li data-bind-iterate="." class="ui-tabs-selected ui-state-active"><a href="#ui-tabs-1" data-bind="createTabLink" data-bind-type="function" class="JQtab">Attack Correlation Details</a></li>

                    <li data-bind-iterate="" iterate-limit="" class=""><a href="#ui-tabs-2" data-bind="createTabLink" data-bind-type="function" class="JQtab">Common Details</a></li><li data-bind-iterate="" iterate-limit="" class=""><a href="#ui-tabs-3" data-bind="createTabLink" data-bind-type="function" class="JQtab">Exposure Details</a></li><li data-bind-iterate="" iterate-limit="" class=""><a href="#ui-tabs-4" data-bind="createTabLink" data-bind-type="function" class="JQtab">IP Reputation Feed</a></li><li 
May 7, 2013 at 6:16 AM
Hi deepakguna,

Here is some sample code that works:

Test method:
        public void Launch_ObjectRepositoryTempHtmlFile_CanFindUnorderedListsByTagAndClassName()
            // Arrange
            using (TempFile tempFile = new TempFile(
        <div id=""feed_tabs"" class=""ui-tabs"">
            <ul class=""dataFeedTab ui-tabs-nav"">
                <li data-bind-iterate=""."" class=""ui-tabs-selected ui-state-active"">
                    <a href=""#ui-tabs-1"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">Attack Correlation Details</a>
                <li data-bind-iterate="""" iterate-limit="""" class="""">
                    <a href=""#ui-tabs-2"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">Common Details</a>
                <li data-bind-iterate="""" iterate-limit="" class="">
                    <a href=""#ui-tabs-3"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">Exposure Details</a>
                <li data-bind-iterate="" iterate-limit="" class=""><a href=""#ui-tabs-4"" data-bind=""createTabLink"" data-bind-type=""function"" class=""JQtab"">IP Reputation Feed</a>
                // Act
                HtmlTestPageFeeds window = CUITe_BrowserWindow.Launch<HtmlTestPageFeeds>(tempFile.FilePath);

                // Assert
public class HtmlTestPageFeeds : CUITe_BrowserWindow
        public HtmlTestPageFeeds()
            : base("test")

        public CUITe_HtmlUnorderedList cusDataFeedTabsNav
                return this.Get<CUITe_HtmlUnorderedList>("Class=dataFeedTab ui-tabs-nav;TagName=ul");

        public CUITe_HtmlDiv divFeedTabs
                return this.Get<CUITe_HtmlDiv>("Id=feed_tabs");

        public CUITe_HtmlUnorderedList cusdatafeedtabsnav1
                return (this.divFeedTabs.Get<CUITe_HtmlUnorderedList>("Class=dataFeedTab ui-tabs-nav;TagName=ul"));
May 7, 2013 at 7:48 AM
Thank you icnocop!

But i am wondering why it is not finding as CUITe_HtmlCustom while it has no problem with _HtmlCustom
May 7, 2013 at 8:12 AM
It's because all the CUITe_HtmlCustom constructors takes the tagName as the first parameter, and not searchParameters.

It seems this is also causing the .Get<T>() method to not work as expected.
May 7, 2013 at 8:18 AM
Tagname should be part of searchParameter.
May 10, 2013 at 10:27 PM
I'm having similar issues using the .Get<T>(searchParam) method to retrieve List items and other "Custom" control types. I'm using VS2012 with the latest release ( Commit 25457). Is it possible that there is an issue with using the Get<T>(searchParam) method for custom types?

Just wondering if I'm the only one having trouble with custom types, I may post a more detailed discussion topic once I gather more info.
May 13, 2013 at 6:25 AM
Hi yourmaster27, try providing tagname as the first parameter. This is the difference between CUITe_HtmlCustom and other controls.
May 13, 2013 at 8:37 PM
So unfortunately providing the tag name didn't seem to make a difference for me. Presently the crux of my issue is due to existing tests that run in VS 2010, but aren't making the switch to 2012 cleanly. For example:

Here is the Html:
<a href="javascript:void(0)" class="chzn-single chzn-default" id="usersCompany_chzn_link">
<div class="chzn-drop" style="left: 0px; width: 350px; top: 20px;">
    <div class="chzn-search"> ... </div>
    <ul class="chzn-results">
        <li id="usersCompany_chzn_o_0" class="active-result" style="">Item1</li>
        <li id="usersCompany_chzn_o_1" class="active-result" style="">Item2</li>
        <li id="usersCompany_chzn_o_2" class="active-result" style="">Item3</li>
And this is the CUITe test code that work in 2010 but not 2012
 //Where ElementLink is  var Elementlink = Get<CUITe_HtmlHyperlink>("id=usersCompany_chzn_link")
        public CUITe_HtmlControl<HtmlCustom> getDropDownElement(string ListItemName, CUITe_HtmlHyperlink Elementlink)
            CUITe_HtmlDiv theUserList = (CUITe_HtmlDiv)Elementlink.NextSibling;

            //Original method call, works in 2010 but not 2012
            ////CUITe_HtmlListItem item = theUserList.Get<CUITe_HtmlListItem>("InnerText=" + ListItemName");

            CUITe_HtmlUnorderedList uList = theUserList.Get<CUITe_HtmlUnorderedList>("class=chzn-results");
            CUITe_HtmlListItem item= uList.Get<CUITe_HtmlListItem>("TagName=li;InnerText=" + ListItemName);
            //These are also all invalid in 2012            
            ////CUITe_HtmlListItem item2 = theUserList.Get<CUITe_HtmlListItem>("TagName=li");
            ////CUITe_HtmlCustom tag = theUserList.Get<CUITe_HtmlCustom>("TagName=LI");         
            ////CUITe_HtmlListItem tag2 = theUserList.Get<CUITe_HtmlListItem>();            
            return item;
None of these Gets for UnodreredLists or ListItems actually return usable objects in 2012. Anyone have any clue why the same code won't work in both versions of visual studio? Thanks!
May 14, 2013 at 8:54 AM
I've just checked in some code that fixes the issue with custom controls and also allows passing in the TagName in the search parameters.

Commit 26882

See the "Launch_ObjectRepositoryTempHtmlFile_CanFindUnorderedListsByTagAndClassName" test method for sample code.

Thank you.
May 14, 2013 at 4:46 PM
Similar to the latest post in discussion:443509, I too am still getting an exception with Commit 26882.

The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Web'
ControlType: 'Custom'
InnerText: 'AutoTest'
TagName: 'li'

Failed to find any control that matched the search condition ControlType='Custom' && InnerText='AutoTest' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

Any thoughts? Thanks for your time.
May 15, 2013 at 9:26 AM
@yourmaster27, for li elements, use CUITe_HtmlListItem.
May 15, 2013 at 3:13 PM
The exception I posted was the message thrown when using the CUITe_HtmlListItem.
CUITe_HtmlDiv div = Get<CUITe_HtmlDiv>("class=chzn-drop");
CUITe_HtmlListItem theListItem = div.Get<CUITe_HtmlListItem>("TagName=li");
The same code works fine in Visual Studio 2010, but in 2012 it can not resolve the control...
May 16, 2013 at 6:37 AM
Please make sure the html you are testing is valid.

This works for me:
// Arrange
            using (TempFile tempFile = new TempFile(
        <a href=""javascript:void(0)"" class=""chzn-single chzn-default"" id=""usersCompany_chzn_link"" />
        <div class=""chzn-drop"" style=""left: 0px; width: 350px; top: 20px;"">
            <div class=""chzn-search""> ... </div>
            <ul class=""chzn-results"">
                <li id=""usersCompany_chzn_o_0"" class=""active-result"" style="""">Item1</li>
                <li id=""usersCompany_chzn_o_1"" class=""active-result"" style="""">Item2</li>
                <li id=""usersCompany_chzn_o_2"" class=""active-result"" style="""">Item3</li>
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");

                // Act
                CUITe_HtmlHyperlink link = window.Get<CUITe_HtmlHyperlink>("id=usersCompany_chzn_link");

                CUITe_HtmlDiv drop = window.Get<CUITe_HtmlDiv>("class=chzn-drop");

                CUITe_HtmlListItem item1 = drop.Get<CUITe_HtmlListItem>("InnerText=Item1");

                CUITe_HtmlUnorderedList results = drop.Get<CUITe_HtmlUnorderedList>("class=chzn-results");
                CUITe_HtmlListItem item2 = results.Get<CUITe_HtmlListItem>("InnerText=Item2");

                // Assert

Jul 22, 2013 at 9:42 AM
Edited Jul 23, 2013 at 3:12 PM
Hi icnocop, thank for quick response, now i've one some issue. Please help as you can)My example code below
<div class="buttons">
<div class="list_but">
<a href="/transactions?example=/param?type=wallet"><span></span></a>
<div class="add_funds">
<a class="LoadFundsBtn" href="/example/param?currencyName=USD">
coded ui code
 CUITe_HtmlDiv mybutton= elogin.Get<CUITe_HtmlDiv>("class=list_but;href~/param?type=wallet");
 Assert.IsTrue(mybutton.Exists, "button not found");
Return an error, how to assert hyperlink with parameters like this "/transactions?type=wallet"
Thanks in advance!
Test Name:  overview
Test FullName:  test.Overview.overview
Test Source:    Overview.cs : line 30
Test Outcome:   Failed
Test Duration:  0:00:14,161023

Result Message: Метод проверки ePaymentsMainWebPage.Overview.overview выдал исключение: System.Reflection.TargetInvocationException: Адресат вызова создал исключение. ---> CUITe.CUITe_InvalidSearchKey: Search Pattern Key not supported -> 'href~/transactions?type' in 'class=list_but;href~/transactions?type=wallet'. Available Properties: DisplayText, HelpText, Class, ControlDefinition, Id, InnerText, TagInstance, TagName, Title, Type, ValueAttribute, AccessKey, BoundingRectangle, ControlType, Name, FriendlyName, ClassName, NativeElement, TechnologyName, IsTopParent, TopParent, WindowHandle, Exists, Enabled, HasFocus, Instance, MaxDepth, Height, Width, Top, Left, State, UITechnologyElement, QueryId.
Result StackTrace:  
в CUITe.Controls.CUITe_ControlBase`1..ctor(String searchProperties) в c:\Working\codeplex\cuite\CUITe\Controls\CUITe_ControlBase.cs:строка 113
   в CUITe.Controls.HtmlControls.CUITe_HtmlControl`1..ctor(String searchParameters) в c:\Working\codeplex\cuite\CUITe\Controls\HtmlControls\CUITe_HtmlControl.cs:строка 20
   в CUITe.Controls.HtmlControls.CUITe_HtmlDiv..ctor(String searchParameters) в c:\Working\codeplex\cuite\CUITe\Controls\HtmlControls\CUITe_HtmlDiv.cs:строка 8
 --- Конец трассировки стека внутреннего исключения ---
    в System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   в System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   в System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   в System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   в System.Activator.CreateInstance(Type type, Object[] args)
   в CUITe.Controls.CUITe_ControlBaseFactory.Create[T](String sSearchProperties) в c:\Working\codeplex\cuite\CUITe\Controls\CUITe_ControlBase.cs:строка 28
   в CUITe.Controls.HtmlControls.CUITe_BrowserWindow.Get[T](String searchParameters) в c:\Working\codeplex\cuite\CUITe\Controls\HtmlControls\CUITe_BrowserWindow.cs:строка 180
   в ePaymentsMainWebPage.Overview.overview() в c:\Users\apak\Documents\Visual Studio 2012\Projects\ePa\ePaymentsMainWebPage\Overview.cs:строка 51
Jul 31, 2013 at 6:11 AM
Hi alekseyp,

Unfortunately, this is an issue with the way CUITe currently parses the search parameters.

Specifically, there is an incompatibility with having both = and ~ in the same search parameter.

Here is another way I can suggest to resolve your issue with the sample code you provided:
CUITe_HtmlDiv div = window.Get<CUITe_HtmlDiv>("class=list_but");
CUITe_HtmlHyperlink link = div.GetChildren()[0] as CUITe_HtmlHyperlink;
Assert.IsTrue(link.Exists, "button not found");
Sep 4, 2013 at 8:12 AM
Try identifying the parent control of the custom control you want to access ... first if you are able to locate parent (use drawhighlight to be sure..!) ,
Then you script should be able to perform actions on the child control also(Use getchildren method ).