none
How to get header items from a datagrid RRS feed

  • Question

    • Hi ,

      I am able to get the header  from the datagrid table but when I am trying get the header items present inside the header , I am getting following

            WpfControl gridColumnHeader =  modalityDirectoryWinObj.Find<CUITe.Controls.WpfControls.WpfControl>(       (By.AutomationId("PART_ColumnHeadersPresenter"));

             When I try to get children, for fetching the column header, it was returning 0.
    •  I am using CUITe framework.

           How to get column headers from the grid?

          Thanks & Regards

         Bharat

    Thursday, April 19, 2018 2:03 PM

All replies

  • Hi Bharat,

    How did you get the children, any code sample?

    Usually 

    foreach (UITestControl x in myControl.GetChildren())

    will work.

    Btw, could you please use Coded Ui test builder to capture the column so check its search properties?

     

    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.


    • Edited by Fletch Zhou Friday, April 20, 2018 6:18 AM
    • Proposed as answer by Fletch Zhou Wednesday, April 25, 2018 10:10 AM
    Friday, April 20, 2018 6:18 AM
  • Hi Fletch,

    I am getting below error in vs 2015 when i tried getting columnheader. It seems it is not supported

    Exception of type 'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll but was not handled in user code

    Additional information: The following element is no longer available: Name [], ControlType [ColumnHeader], AutomationId [], RuntimeId [7,8712,46595510]

    Also i tried 

     WpfControl header = filegrid.Find<WpfControl>(By.ControlType("Header"));
      UITestControlCollection columnHeaders = header.SourceControl.GetChildren(); 

     Returning null

    Please help me how to find the columnheader of a WpfTable

    Thanks

    Bharat

    Saturday, May 5, 2018 6:09 AM
  • Hi Bharat,

    I’m afraid the developer did not specified the children items automationID, to confirm it you may use Coded UI test builder to capture them to see if you can get the corresponding search properties.

    But you just want get specific one of the items, you may try below:

           (1)Use the Codedui to record it and get the header items that you can fetch;

                          (2)Then get the header items present inside the header use the Coordinate

                          (3)Code: WpfButton uIStartButton = this.UIMainWindowWindow.UIStartButton;

    Mouse.Click(new Point(UIMainWindowWindow.BoundingRectangle.X + 277, UIMainWindowWindow.BoundingRectangle.Y + 193));

    By using above method, you can get the header items present inside the header and click it successfully.

    And following document as Creating, Editing and Maintaining a Coded UI Test, please have a look at it.

    https://msdn.microsoft.com/en-us/library/ff977233.aspx

     

    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.


    Monday, May 7, 2018 8:57 AM