CodedUI SearchProperties not working for FriendlyName or ControlName

Category: visual studio mtm

Question

John31017 on Fri, 01 Jul 2016 10:01:14


Hi, 

I'm using the Coded UI framework in visual studio Enterprive 2015 to automate a Windows application. 


The Login screen for this application contains a username and password field. The password field has a control type 'Edit' and Name of 'PasswordTextEdit'. However the Username field does not have a name field specified. But it does have ControlName and FriendlyName. So I have adjusted the UI Map to Search for ControlName or FriendlyName, however Coded UI can't find this field. It can find the password field without any problems though. 

This is the UIMap entries for both fields and i've tried both of these lines in the search criteria region.
this.mUITeUserEdit.SearchProperties[WinEdit.PropertyNames.FriendlyName] = "teUser";
this.mUITeUserEdit.SearchProperties[WinEdit.PropertyNames.ControlName] = "teUser";


    // This doesn't work, nor does it work with either of the above lines positioned directly below the '#region Search Criteria' line.
    public WinEdit UITeUserEdit
    {
        get
        {
            if ((this.mUITeUserEdit == null))
            {
                this.mUITeUserEdit = new WinEdit(this);
                #region Search Criteria
                this.mUITeUserEdit.WindowTitles.Add("FAST Trading Tools (Test) Login");
                #endregion
            }
            return this.mUITeUserEdit;
        }
    }

    // This does work.
    public WinEdit UITePasswordEdit
    {
        get
        {
            if ((this.mUITePasswordEdit == null))
            {
                this.mUITePasswordEdit = new WinEdit(this);
                #region Search Criteria
                this.mUITePasswordEdit.SearchProperties[WinEdit.PropertyNames.Name] = "PasswordTextEdit";
                this.mUITePasswordEdit.WindowTitles.Add("FAST Trading Tools (Test) Login");
                #endregion
            }
            return this.mUITePasswordEdit;
        }
    }

Any information or anything else to try is much appreciated.

Thanks,

J.


Replies

Jack Zhai-MSFT on Mon, 04 Jul 2016 12:35:38


Hi Jasper11697,

No error in the code, if possible, I suggest you collect the detailed error messages:

https://msdn.microsoft.com/en-us/library/jj159363.aspx

>>this.mUITeUserEdit.SearchProperties[WinEdit.PropertyNames.FriendlyName] = "teUser";
this.mUITeUserEdit.SearchProperties[WinEdit.PropertyNames.ControlName] = "teUser";

In addition, it seems that the above properties have the same name value, please make sure that you use the Unique property as the search property.

Best Regards,

Jack