Can i use more than one search or filter properties in CUITe object repository

Apr 9, 2013 at 2:03 PM
Edited Apr 10, 2013 at 7:23 AM
Can i use more than one search or filter properties in CUITe object repository?

For eg. i want to give ID,Innertext as search properties and Class as filter properties for a div , how can i do that?


there is way to give multiple search properties separated by ; but how can i provide filter properties.
Apr 11, 2013 at 5:21 AM
Can any one shed some light on this? Can i use filter properties ?
Coordinator
Apr 11, 2013 at 5:39 AM
Hi deepakguna,

Yes, you can use more than one search property; just separate them with a semicolon as follows:
CUITe_HtmlHyperlink closeLink = window.Get<CUITe_HtmlHyperlink>("Title=Close;class=ms-dlgCloseBtn");
If you want to specify filter properties, you can try to do something like this:
closeLink.UnWrap().FilterProperties[HtmlHyperlink.PropertyNames.Class] = "ms-dlgCloseBtn";
May 10, 2013 at 11:23 AM
Edited May 10, 2013 at 11:31 AM
hi icnocop, i've some trouble with separate search properties in the object repository. Could you give some advices for me.
html code:
<div id="slides">
<div class="slide first">
<div class="text">
<div class="button"><a href="/about">about text</a></div>
When i run test with class search property it failed, cause class=button can't be found on the page. If i delete this search property all works fine. I need to use class search property, therefore the same link in the header of the page
<li><a href="/about"><span>About Us</span></a></li>
//Object repository with class search property
public CUITe_HtmlHyperlink about= new CUITe_HtmlHyperlink("InnerText=about text;class=button;");
Hyperlinks search property works fine without any issues, code below:
//Object repository with hyperlink search property
public CUITe_HtmlHyperlink about= new CUITe_HtmlHyperlink("InnerText=about text;href~about");
May 14, 2013 at 7:51 AM
could anybody advice me?
May 14, 2013 at 8:24 AM
The class is for div not for link

you try getting the link with innertext withing that div
May 14, 2013 at 11:14 AM
Edited May 14, 2013 at 11:14 AM
deepakguna wrote:
The class is for div not for link

you try getting the link with innertext withing that div
i've change my code to
public CUITe_HtmlDiv about= new CUITe_HtmlDiv("InnerText=about text;class=button");and have an error again, could you give the sample code?
Coordinator
May 15, 2013 at 9:24 AM
Hi alekseyp,

Can you use the properties the built-in Coded UI recorder uses?

This works for me:
// Arrange
            using (TempFile tempFile = new TempFile(
@"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""button""><a href=""/main"">main text</a></div>
        <div class=""button""><a href=""/about"">about text</a></div>
    </body>
</html>"))
            {
                CUITe_BrowserWindow.Launch(tempFile.FilePath);
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");

                // Act
                CUITe_HtmlDiv div = window.Get<CUITe_HtmlDiv>("class=button");

                CUITe_HtmlHyperlink about = window.Get<CUITe_HtmlHyperlink>("InnerText=about text;href~about");
                CUITe_HtmlDiv div2 = about.Parent as CUITe_HtmlDiv;

                // Assert
                Assert.IsTrue(div.Exists);
                Assert.AreEqual("main text", div.UnWrap().InnerText);

                Assert.IsTrue(about.Exists);

                Assert.IsTrue(div2.Exists);
                Assert.AreEqual("about text", div2.UnWrap().InnerText);

                window.Close();
            }
May 16, 2013 at 2:40 PM
The Built-in Coded UI recorder looks like not friendly, and i want to write my hand code with CUITe coded ui.
Example code with built-in coded ui
 /// <summary>
 /// Verify that the 'ControlDefinition' property of class equals class="associate active"'
 /// </summary>
public string CustomControlDefinition = "class=\"associate active\"";

 public HtmlCustom CustomControlDefinition 
        {
            get
            {
                if ((this.mCustomControlDefinition  == null))
                {
                    this.CustomControlDefinition  = new HtmlCustom(this);
                    #region Search Criteria
                    this.CustomControlDefinition SearchProperties["TagName"] = "LI";
                    this.CustomControlDefinition .SearchProperties["Id"] = null;
                    this.CustomControlDefinition .SearchProperties[UITestControl.PropertyNames.Name] = null;
                    this.CustomControlDefinition .FilterProperties["Class"] = "associate active";
                    this.CustomControlDefinition .FilterProperties["ControlDefinition"] = "class=\"associate active\"";
                    this.CustomControlDefinition .FilterProperties["InnerText"] = "inner text";
                    this.CustomControlDefinition .FilterProperties["TagInstance"] = "6";
                    this.CustomControlDefinition .WindowTitles.Add("title example");
                    #endregion
                }
                return this.mCustomControlDefinition ;
            }
        }
Coordinator
May 17, 2013 at 6:04 AM
For <li /> elements, use CUITe_HtmlListItem.

For example:
CUITe_HtmlListItem associateActiveItem = this.Get<CUITe_HtmlListItem>("class=associate active;InnerText=inner text");
May 17, 2013 at 8:01 AM
The type or name space TempFile could not be found...
Where you define this type?I've VS 2012 Ultimate Edition
Image
Coordinator
May 17, 2013 at 8:41 AM
TempFile.cs is part of Sample_CUITeTestProject in the "Source Code" (tab).

Here is a link to the latest version.
May 17, 2013 at 8:55 AM
icnocop wrote:
For <li /> elements, use CUITe_HtmlListItem.

For example:
CUITe_HtmlListItem associateActiveItem = this.Get<CUITe_HtmlListItem>("class=associate active;InnerText=inner text");
Thank you very much!This work as well!