none
Automation ID is not getting reflected on the UI if we use automation framework

    Question

  • I have used automation framework to assign unique value(name or ID)to custom controls in Silverlight application. But the unique name or ID is not getting reflected on the UI. Please find the snippet below.

    I have used the Name property and assigned value to it as mentioned below:-

    x:Name ="control name"

    Below is the code I have added in the corresponding .xaml page of the particular control:-

     protected override AutomationPeer OnCreateAutomationPeer()
            {
                return new AUIEllipseUserControlAutomationPeer(this);
            }

            public AUIEllipseUserControl()
            {
                InitializeComponent();         
            }

     private class AUIEllipseUserControlAutomationPeer : FrameworkElementAutomationPeer
            {

                public AUIEllipseUserControlAutomationPeer(FrameworkElement owner)
                    : base(owner)
                {
                    if (!(owner is AUIEllipseUserControl))
                        throw new ArgumentOutOfRangeException();
                }

                protected override string GetClassNameCore()
                {
                    return "AUIEllipseUserControl";
                }

                protected override AutomationControlType GetAutomationControlTypeCore()
                {
                    return AutomationControlType.Custom;
                }

                protected override bool IsContentElementCore()
                {
                    return true;
                }

                protected override bool IsControlElementCore()
                {
                    return false;
                }
            }

    Kindly provide the solution for the above issue.

    Tuesday, January 2, 2018 6:54 AM

All replies

  • How do you implement the UI test? Are you using Coded UI testing?

     

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, January 4, 2018 8:54 AM