Finding Custom controls

Jun 30, 2009 at 10:29 AM

Hello,

I have a WPF custom control that is created in code and is inherited from Control:

 public class NumericUpDown : Control
 {
    // code is here
 }

My CustomUIItem is:

 [ControlTypeMapping(CustomUIItemType.Custom)]
    public class MyNumericUpDown : CustomUIItem
    {
         public MyNumericUpDown(AutomationElement automationElement, ActionListener actionListener)
            : base(automationElement, actionListener)
        {
        }

       protected MyNumericUpDown() { }
    }
I have a test method that tries to retrieve this custom control control:
 [Test]
 public void CanFindCustomSpinnerControl()
{
            MyNumericUpDown spinner = this.window.Get<MyNumericUpDown>("nud");

            Assert.IsNotNull(spinner);
}
This test fails as the control is null.

Here is a snippet of LogStructure() output relevant to the Custom control:

 AutomationId: nud
    ControlType: ControlType.Spinner
    Name:
    HelpText:
    Bounding rectangle: 428,462,280,126
    ClassName: NumericUpDown
    IsOffScreen: False
    FrameworkId: WPF
    ProcessId: 2232

    System.Windows.Automation.RangeValuePattern

        AutomationId: IncreaseCommand
        ControlType: ControlType.Button
        Name:
        HelpText:
        Bounding rectangle: 601,470,101,53
        ClassName: RepeatButton
        IsOffScreen: False
        FrameworkId: WPF
        ProcessId: 2232

        System.Windows.Automation.InvokePattern

        AutomationId: DecreaseCommand
        ControlType: ControlType.Button
        Name:
        HelpText:
        Bounding rectangle: 601,526,101,54
        ClassName: RepeatButton
        IsOffScreen: False
        FrameworkId: WPF
        ProcessId: 2232

        System.Windows.Automation.InvokePattern

What am I missing?

Thanks

 

 

 

 

Coordinator
Jul 4, 2009 at 10:10 AM

is there a reason you are not using Spinner class which comes with white?

Jul 6, 2009 at 8:29 AM

We're trying to determine 2 things.

1. If we create a custom control can we test it with White?

2. If we buy third-party controls can we test them with white?

 

To test out the first of these we downloaded an example custom control from Microsoft ( google NumericUpDown Custom Control ) and tried to drive it using White. We used the code in section 11 ( Custom UI Item ) as our starting point but we couldn't get it to work. So we're unable to answer the first question. Any help would be greatly appreciated.

Coordinator
Jul 7, 2009 at 7:40 AM

you need to use Spinner instead on Custom for the CustomUIItemType. And you would have to add the mapping as well. I have updated the documentation for same: http://white.codeplex.com/Wiki/View.aspx?title=Custom%20UI%20Item

 

Jul 7, 2009 at 9:25 AM

Thanks very much. I've updated my source code to add a custom spinner type and that worked well.