locked
Reflection Question RRS feed

  • Question

  •  public UIScheduledDeliveryWindow()
            {
                #region Search Criteria
                this.SearchProperties[WinWindow.PropertyNames.Name] = "Scheduled Delivery";
                this.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains));
                this.WindowTitles.Add("Scheduled Delivery");
                #endregion
            }
    When recording a session, one of the controls shows up as a UIScheduledDeliveryWindow per above in one of our codedui classes.  It is of type: 
    WindowsForms10.Window

    There is a calendar control within this window.  But it doesn't show up even when doing SPY++, so I assume this is some type of custom control of which I did figure out how to manipulate it using another Calendar model.

    Question is this: Is there any way to actually get an instance of this class type as an object of it's managed class?  I assume that WindowsForm10 is a System.Windows.Form.Form class.  I was thinking if I could get the native managed represented Object type I would be able to manipulate it easier...  

    I've tried to figure out what a WindowsForm10 class is about and can see that it is a specific class known only to the Automation Test Framework.  But it does have a HWND.  I'm thinking that I could get an instance of the object using the HWND and System.Windows.Form classes...  Any ideas?


    JP Cowboy Coders Unite!

    Monday, December 10, 2012 4:50 PM

Answers

  • Hello Mr.JavaMan,

    Thank you for your post.

    I have tried a Coded UI test with a Windows Forms application. I notice that the ClassName properties of those controls on the winforms application UI all start with WindowsForms10. For example the DateTimePickerWindow control has “WindowsForms10.SysDateTimePicker32.app.0.2bf8098_r15_ad1” ClassName.

    I have consulted a testing expert.  As he told that the WindowsForm10 is just an interface the control property exposes rather than the System.Windows.Form class. So we can’t get the Object from it. And you can get the instance of the object using HWND and System.Windows.Form class. But this is not applied in Coded UI test. You can do this during developping the Windows Forms application.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 11, 2012 8:11 AM
    Moderator

All replies

  • The trick I used to get the proper calendar date mapping was this:

    • First record the click for all dates on calendar and name them correctly  DateR1C1, DateR1C2 etc.
    • Then create an actual Calendar control so that you can also name each date DateR1C1, DateR1C2, except the real calendar control now has the actual dates and not just the X, Y, coordinates from first mapped class.
    • Write a mediator class that maps the real dates with the method (clicks) represented by the first mappings.  The result will be "DateR1C1", ActualDateRepresented, Action.  Where the Action is this: Action act = new Action(DateR1C1);  
    • This gives me the ability to find a date and click the "Action" which is really just an X, Y coordinate on first map...  

    While this works well, it took a bit of in-depth analysis and coding to get there.  Surely there's a better way..


    JP Cowboy Coders Unite!

    Monday, December 10, 2012 4:56 PM
  • Hello Mr.JavaMan,

    Thank you for your post.

    I have tried a Coded UI test with a Windows Forms application. I notice that the ClassName properties of those controls on the winforms application UI all start with WindowsForms10. For example the DateTimePickerWindow control has “WindowsForms10.SysDateTimePicker32.app.0.2bf8098_r15_ad1” ClassName.

    I have consulted a testing expert.  As he told that the WindowsForm10 is just an interface the control property exposes rather than the System.Windows.Form class. So we can’t get the Object from it. And you can get the instance of the object using HWND and System.Windows.Form class. But this is not applied in Coded UI test. You can do this during developping the Windows Forms application.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 11, 2012 8:11 AM
    Moderator
  • Hello Mr.Javaman,

    I am marking my reply as answer. If my suggestion can’t help you, you can come back and unmark it as answer. If you have anything unclear, please feel free to come back and ask me.

    Best reagrds,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 13, 2012 12:22 AM
    Moderator