Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:02:25+00:00 2026-06-05T00:02:25+00:00

I am trying to test some custom controls with the UI Automated framework. One

  • 0

I am trying to test some custom controls with the UI Automated framework. One of my controls has a base class of TextBox and the other inherits from Control. I can find my first control with my tests, however no matter what combination I use of TreeScope and property conditions, I cannot find my second custom control within the window.

I declare the custom control in the XAML like so:

<Grid>
    <test:CustomTextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="customTextBox1" VerticalAlignment="Top" Width="120" />
    <test:CustomUserControl Height="25" HorizontalAlignment="Left" Margin="12,62,0,0" Name="customUserControl1" VerticalAlignment="Top" Width="119" />
</Grid>

I have a sample test like the one below.

[Test]
public void TestUsingValuePattern()
{
    // Getting RootElement...
    AutomationElement rootElement = AutomationElement.RootElement;
    Assert.IsNotNull(rootElement);

    // Searching for Test Window...
    AutomationElement windowElement = rootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "TestWindow"));
    Assert.IsNotNull(windowElement);

    // Searching for Custom TextBox control...
    AutomationElement customElement1 = windowElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "customTextBox1"));
    Assert.IsNotNull(customElement1);

    // Searching for Custom User control
    AutomationElement customElement2 = windowElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "customUserControl1"));
    Assert.IsNotNull(customElement2);
}

Second assertion always returns null so I can’t even get started running tests on it. Any suggestions here on what I could possibly do to fix this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:02:27+00:00Added an answer on June 5, 2026 at 12:02 am

    It looks like you may need to set the AutomationId property in the XAML for it to show up – it doesn’t look like the Name property gets exposed as AutomationId.

    You might also want use the inspect tool to check that the elements are actually exposed in the automation tree, and have the AutomationId or other properties that you expect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some Unit Tests to test some custom NSOperations that
I'm trying to test an app that creates some custom permissions during intialization. These
I am trying to test some exceptions in my project and one of the
I am trying to raise some custom events to a SqlWebEventProvider from a windows
I'm trying to write a test for an model which has both some normal
I am ultimately trying to unit test a custom base adapter, but I am
I'm trying to make a custom control inherited from TextBox. I'm looking to do
I'm trying to make a custom report. I've just put some test code on
I am trying to create a custom Dojo ValidationIdBox widget that inherits from ValidationTextBox.
I'm trying to test some TPL dataflow code and run into what looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.