locked
Technology Element for Password control changes RRS feed

  • Question

  • Hi,

    I am trying to compare a technologyelement of a password control before doing an action with the one after doing the action, i.e., it is the same technologyelement but I am storing the initial one and comparing it with the one obtained after performing the action.  The action is SendKeys.

    What I see is that both are different.  I am using the 'Equals' method for comparison.

    This is seen even for the Gmail password control on Gmail website. (www.gmail.com).

    Below is the sample code that I used -

    // ------------------------------------------------------------------------------
    //  <auto-generated>
    //      This code was generated by coded UI test builder.
    //      Version: 10.0.0.0
    //
    //      Changes to this file may cause incorrect behavior and will be lost if
    //      the code is regenerated.
    //  </auto-generated>
    // ------------------------------------------------------------------------------
    
    namespace TestProject3
    {
        using System;
        using System.CodeDom.Compiler;
        using System.Collections.Generic;
        using System.Drawing;
        using System.Text.RegularExpressions;
        using System.Windows.Input;
        using Microsoft.VisualStudio.TestTools.UITest.Extension;
        using Microsoft.VisualStudio.TestTools.UITesting;
        using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
        using Microsoft.VisualStudio.TestTools.UnitTesting;
        using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
        using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;
        using MouseButtons = System.Windows.Forms.MouseButtons;
    using System.Security;
        using System.Runtime.InteropServices;
        
        
        [GeneratedCode("Coded UITest Builder", "10.0.40219.1")]
        public partial class UIMap
        {
            
            /// <summary>
            /// RecordedMethod1 - Use 'RecordedMethod1Params' to pass parameters into this method.
            /// </summary>
            public void RecordedMethod1()
            {
                #region Variable Declarations
                HtmlEdit uIPasswordEdit = this.UIGmailEmailfromGoogleWindow.UIGmailEmailfromGoogleDocument.UIPasswordEdit;
                #endregion
    
                UITechnologyElement uIPasswordEditTechElement = (UITechnologyElement)uIPasswordEdit.GetProperty(UITestControl.PropertyNames.UITechnologyElement);
    
                Mouse.Click(uIPasswordEdit);
    
                while (true)
                {
                    UITestControl foregroundWindowTestControl = UITestControlFactory.FromWindowHandle(SafeNativeMethods.GetForegroundWindow());
                    UITechnologyManager foregroundWindowTechnologyManager = Playback.GetCoreTechnologyManager(foregroundWindowTestControl.TechnologyName);
                    UITechnologyElement focusedTechnologyElement = (UITechnologyElement)foregroundWindowTechnologyManager.GetFocusedElement(SafeNativeMethods.GetForegroundWindow());
    
    
    
                    if (focusedTechnologyElement.Equals(uIPasswordEditTechElement))
                    {
                        Keyboard.SendKeys(UITestControlFactory.FromNativeElement(focusedTechnologyElement.NativeElement, focusedTechnologyElement.TechnologyName), "aaa");
                    }              
                    
                }
    
                //// Type '********' in 'Password' text box
                //uIPasswordEdit.Password = this.RecordedMethod1Params.UIPasswordEditPassword;
            }
            
            #region Properties
            public virtual RecordedMethod1Params RecordedMethod1Params
            {
                get
                {
                    if ((this.mRecordedMethod1Params == null))
                    {
                        this.mRecordedMethod1Params = new RecordedMethod1Params();
                    }
                    return this.mRecordedMethod1Params;
                }
            }
            
            public UIGmailEmailfromGoogleWindow UIGmailEmailfromGoogleWindow
            {
                get
                {
                    if ((this.mUIGmailEmailfromGoogleWindow == null))
                    {
                        this.mUIGmailEmailfromGoogleWindow = new UIGmailEmailfromGoogleWindow();
                    }
                    return this.mUIGmailEmailfromGoogleWindow;
                }
            }
            #endregion
            
            #region Fields
            private RecordedMethod1Params mRecordedMethod1Params;
            
            private UIGmailEmailfromGoogleWindow mUIGmailEmailfromGoogleWindow;
            #endregion
        }
        
       [SuppressUnmanagedCodeSecurityAttribute()]
    public sealed class SafeNativeMethods
    {
    	private SafeNativeMethods()
    	{
    	}
           	
    	[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    	public static extern IntPtr GetForegroundWindow();
    
    	[DllImport("user32.dll")]
    	public static extern uint GetWindowThreadProcessId(IntPtr windowHandle, ref uint processId);
    
    }
    
        /// <summary>
        /// Parameters to be passed into 'RecordedMethod1'
        /// </summary>
        [GeneratedCode("Coded UITest Builder", "10.0.40219.1")]
        public class RecordedMethod1Params
        {
            
            #region Fields
            /// <summary>
            /// Type '********' in 'Password' text box
            /// </summary>
            public string UIPasswordEditPassword = "s+oNDSJUp0OATBaKOjZMtA==";
            #endregion
        }
        
        [GeneratedCode("Coded UITest Builder", "10.0.40219.1")]
        public class UIGmailEmailfromGoogleWindow : BrowserWindow
        {
            
            public UIGmailEmailfromGoogleWindow()
            {
                #region Search Criteria
                this.SearchProperties[UITestControl.PropertyNames.Name] = "Gmail: Email from Google";
                this.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
                this.WindowTitles.Add("Gmail: Email from Google");
                #endregion
            }
            
            public void LaunchUrl(System.Uri url)
            {
                this.CopyFrom(BrowserWindow.Launch(url));
            }
            
            #region Properties
            public UIGmailEmailfromGoogleDocument UIGmailEmailfromGoogleDocument
            {
                get
                {
                    if ((this.mUIGmailEmailfromGoogleDocument == null))
                    {
                        this.mUIGmailEmailfromGoogleDocument = new UIGmailEmailfromGoogleDocument(this);
                    }
                    return this.mUIGmailEmailfromGoogleDocument;
                }
            }
            #endregion
            
            #region Fields
            private UIGmailEmailfromGoogleDocument mUIGmailEmailfromGoogleDocument;
            #endregion
        }
        
        [GeneratedCode("Coded UITest Builder", "10.0.40219.1")]
        public class UIGmailEmailfromGoogleDocument : HtmlDocument
        {
            
            public UIGmailEmailfromGoogleDocument(UITestControl searchLimitContainer) : 
                    base(searchLimitContainer)
            {
                #region Search Criteria
                this.SearchProperties[HtmlDocument.PropertyNames.Id] = null;
                this.SearchProperties[HtmlDocument.PropertyNames.RedirectingPage] = "False";
                this.SearchProperties[HtmlDocument.PropertyNames.FrameDocument] = "False";
                this.FilterProperties[HtmlDocument.PropertyNames.Title] = "Gmail: Email from Google";
                this.FilterProperties[HtmlDocument.PropertyNames.AbsolutePath] = "/ServiceLogin";
                this.FilterProperties[HtmlDocument.PropertyNames.PageUrl] = "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&conti" +
                    "nue=https://mail.google.com/mail/?tab%3Dwm&scc=1&ltmpl=default&ltmplcache=2";
                this.WindowTitles.Add("Gmail: Email from Google");
                #endregion
            }
            
            #region Properties
            public HtmlEdit UIPasswordEdit
            {
                get
                {
                    if ((this.mUIPasswordEdit == null))
                    {
                        this.mUIPasswordEdit = new HtmlEdit(this);
                        #region Search Criteria
                        this.mUIPasswordEdit.SearchProperties[HtmlEdit.PropertyNames.Id] = "Passwd";
                        this.mUIPasswordEdit.SearchProperties[HtmlEdit.PropertyNames.Name] = "Passwd";
                        this.mUIPasswordEdit.FilterProperties[HtmlEdit.PropertyNames.LabeledBy] = "Password";
                        this.mUIPasswordEdit.FilterProperties[HtmlEdit.PropertyNames.Type] = "PASSWORD";
                        this.mUIPasswordEdit.FilterProperties[HtmlEdit.PropertyNames.Title] = null;
                        this.mUIPasswordEdit.FilterProperties[HtmlEdit.PropertyNames.Class] = null;
                        this.mUIPasswordEdit.FilterProperties[HtmlEdit.PropertyNames.ControlDefinition] = "id=Passwd value=\"\" type=password name=Pa";
                        this.mUIPasswordEdit.FilterProperties[HtmlEdit.PropertyNames.TagInstance] = "15";
                        this.mUIPasswordEdit.WindowTitles.Add("Gmail: Email from Google");
                        #endregion
                    }
                    return this.mUIPasswordEdit;
                }
            }
            #endregion
            
            #region Fields
            private HtmlEdit mUIPasswordEdit;
            #endregion
        }
    }
    

    We expected the technology elements to be same at any point of time because it is the same control.  We observed that the UniqueIdentifier property is differing.

    Any help is appreciated.


    sirisha

    Tuesday, July 31, 2012 6:21 AM

All replies

  • Hi sirisha,

    Thank you for posting in the MSDN forum.

    Which kind of app are you testing? Is it the WinForms app or others?

    Did you get any error message when you run your test?

    Not very sure about this issue, do you mean that you want to compare the password which is inputted when your record the test, did you using the database for the password in your test? If so, I think you could compare the password inputted with the passwords in the database.

    I did some research about comparing the password, I find some useful threads, and if possible, you could check it.

    compare password

    Login form - password comparison

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, August 2, 2012 4:30 AM
    Moderator
  • Jack,

    Thanks for the quick response.

    I am not trying to compare the password inputs.

    I am actually trying to compare the technology element of the password control prior to inputting a character into the password edit and after inputting a character into the password control.

    It is seen all the password controls irrespective of the technology. The code shared in my first post reproduces the problem on gmail password control.

    Looking forward for the reply.

    Thanks n Regards,

    sirisha


    sirisha

    Monday, August 6, 2012 1:49 PM
  • Hi sirisha,

    Sorry for our reply no help.

    Based on your test code, I’m afraid that I couldn’t find the real solution, maybe you could share us your app, since the coded UI test depend on the app. We try to debug it, since your write your handle code in the coded UI test, maybe you could try to debug your test,  you could add a breakpoint in your test, and then try to check the variable value in the watch or local window, and then find useful information.  

    Note: if you want to debug a test, you could right click your test in the test view window, select “Debug Selection”.

    If still no help, I suggest you share us your project, please attach your Visual Studio project, you can upload it to the sky driver, and then share the download link in your post.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 7, 2012 3:36 AM
    Moderator
  • Hi Jack,

    As I said in my earlier post, this problem can be reproduced with any password control irrespective of technology.

    Thanks,

    sirisha


    sirisha

    Wednesday, September 26, 2012 11:07 AM
  • Hi Jack,

    Is there any update on this?

    Thanks,

    Sirisha


    sirisha

    Monday, October 1, 2012 8:47 AM