none
Can we find an object (AutomationElement) by its Value's ControlPatterns? RRS feed

  • Question

  • Hi all,

    I am trying to implement an automation testing project using MS UI Automation.

    I have a table with below properties:

      Identification
        ClassName:    "WindowsForms10.Window.8.app.0.297b065"
        ControlType:    "ControlType.Table"
        Culture:    "(null)"
        AutomationId:    "grdTrDefinition"
        LocalizedControlType:    "table"

    This table have many row which have the same properties. Their different is the value as below

    ControlPatterns
      Invoke

      Value
        Value:    "---value---"
        IsReadOnly:    "True"

     

    I can get table as AutomationElement but I could not get its cell. I tried some solutions but they didn't work.

    Could you please show me how to get a cell as an AutomationElement in this case? I just want to check if it exists

     

    Thanks you.

    • Moved by Mathew Aniyan MSFT Thursday, June 16, 2011 3:18 PM Question on UIA (From:Visual Studio UI Automation Testing (includes CodedUI))
    Thursday, June 16, 2011 8:06 AM

All replies

  • Hi, Phong,

    I'm not quite sure what you mean when you say you could not get its cell.  Can you see anything underneath the table element with either the UISpy or the Inspect tool?

    In other words, I'm not sure if you are wondering whether that table is accessible at all, or whether you are asking how exactly to find the cell you care about.

    Thanks,
    Michael


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, June 17, 2011 6:45 PM
  • Hi Michael,

     

    Thanks for your response.

    I am sorry because of my unclear question. For now, my question is "how do I find an AutomationElement by its value in ControlPatterns > Value > Value as below tree?"

    ControlPatterns
      Invoke

      Value
        Value:    "---value---"
        IsReadOnly:    "True"

    In case there is no way to find it, please show me another way to get that value or assert if this object (which specify value) is existing.

     

    Thanks,

    Phong


    Monday, June 20, 2011 8:14 AM
  • Hi, Phong,

    Assuming that the table and all of its cells are actually accessible, I think there are basically 2 approaches:

    1. Use AutomationElement.FindFirst and use a PropertyCondition to check if IsValuePatternAvailable is true.  That will search the tree for an element that has a value pattern, which sounds like what you were looking for.

    2. Use a TreeWalker to walk through the tree and check each element against your conditions.  This would be more time consuming, but gives you more flexibility to check for exactly what you are seeking.

    [You could do either of these approaches with the UIA COM API (IUIAutomation) also, if you were working in native code.]

    If you know exactly what value you are looking for, you would do approach (1), but use a property condition that checked for whether the Value property was equal to the string you were looking for.

    Thanks,
    Michael


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 1, 2011 4:05 PM