SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Advanced Member
    Join Date
    Mar 2007
    Location
    Salt Lake City, UT, USA
    Posts
    606
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Dump all object properties

    What I'd like to do is write a little script that would allow me to capture every property of an object and dump them out to the test log.

    My ultimate goal is to generate two lists of every property of two similar objects so I can set those two lists side by side and visually look at them to find any discrepencies.

    Ideally, this would get all run-time properties (that long, 3-page list of properties I can see in the object Spy if I click the Run-time Object Properties radiobutton).

    Something like this:

    for i = 1 to NumberOfProperties
    x = Window("Account").wpfEdit("AccountNum").GetROPrope rty(i)
    Reporter.ReportEvent micDone, "Property: " & x, "Property: " & x
    next

    Now, what I don't know is how to get those properties like that. I suppose I cannot use GetROProperty at all, and will more likely need to use DP to define the object then get a collection of all the properties, then iterate through that collection and output them one by one.

    Can anyone offer a suggestion as to how this might be done?

    Note: an alternative trick would be to just spy on the object to see all the properties then somehow dump the contents of the spy to a .txt file or something - is there a way to do it through the spy?

    Thanks in advance,
    Blake
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  2. #2
    Senior Member
    Join Date
    Nov 2007
    Posts
    263
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dump all object properties

    Actually I have a function that does this. In my version, I didn't want all the properties so for each type of control I specify which properties I want via an array. You could of course modify this to your needs.

    To call it you would do something like -

    Set oSomeWindow = Window(whatever).Dialog(dialog)

    Since this creates an ArrayList via .Net you would declare the array list to return the values to. At least from this you get the idea of what to do to accomplish the task.

    <font class="small">Code:</font><hr /><pre>
    Function GatherWindowStats( oWindow )
    Set aProperties = CreateObject("System.Collections.ArrayList")
    Dim aType
    aMicClasses = Array("WinObject","WinEdit","WinButton","WinList", "WinComboBox","WinCalendar","WinRadioButton","WinC heckBox","Static")
    aItemsWinObject = Array("window id","attached text","enabled","height","nativeclass","text","wid th")
    aItemsWinEdit = Array("window id","attached text","enabled","height","nativeclass","text","wid th")
    aItemsWinButton = Array("window id","attached text","enabled","height","nativeclass","text","wid th")
    aItemsWinList = Array("window id","attached text","all items","enabled","height","items count","nativeclass","selection","text","width")
    aItemsWinComboBox = Array("window id","attached text","all items","enabled","height","items count","nativeclass","selection","text","width")
    aItemsWinCalendar = Array("window id","attached text","enabled","height","nativeclass","text","wid th")
    aItemsRadioButton = Array("window id","attached text","checked","enabled","height","nativeclass"," text","width")
    aItemsCheckBox = Array("window id","attached text","checked","enabled","height","nativeclass"," text","width")
    aItemsStatic = Array("window id","attached text","enabled","height","nativeclass","text","wid th")

    nClasses = UBound(aMicClasses)

    For nClass = 0 to nClasses
    Set oObjectType = Description.Create
    oObjectType("micClass").value = aMicClasses(nClass)

    Set oCollection = oWindow.ChildObjects(oObjectType)
    nCollectionCount = oCollection.Count

    If nCollectionCount &gt; 0 Then
    For nObject = 0 to oCollection.Count - 1
    'Get the objects hWnd
    hWndObject = oCollection.Item(nObject).GetROProperty("hwnd")
    'Show where we are at
    HighlightWindow hWndObject,1

    Select Case aMicClasses(nClass)
    Case "WinObject"
    aType = aItemsWinObject
    Case "WinEdit"
    aType = aItemsWinEdit
    Case "WinButton"
    aType = aItemsWinButton
    Case "WinList"
    aType = aItemsWinList
    Case "WinComboBox"
    aType = aItemsWinComboBox
    Case "WinCalendar"
    aType = aItemsWinCalendar
    Case "WinRadioButton"
    aType = aItemsRadioButton
    Case "WinCheckBox"
    aType = aItemsCheckBox
    ' Case "WinListView"
    Case "Static"
    aType = aItemsStatic

    End Select

    sSection = "[" + CStr(oCollection.Item(nObject).GetROProperty("wind ow id")) + "]"
    aProperties.Add sSection

    For nItem = 0 to UBound(aType)
    sKey = CStr(aType(nItem))
    sValue = chr(34) + CStr(oCollection.Item(nObject).GetROProperty(aType (nItem))) + chr(34)
    aProperties.Add sKey + "=" + sValue
    Next
    aProperties.Add vbLF
    Next
    End If
    Next
    Set GatherWindowStats = aProperties
    End Function
    </pre><hr />

  3. #3
    Advanced Member
    Join Date
    Mar 2007
    Location
    Salt Lake City, UT, USA
    Posts
    606
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dump all object properties

    Thanks for that. It gets me closer.

    However, I'm looking to capture all 120+ run-time properties of these objects. I suppose I could enter all that into the arrays, but yikes!

    So I would still rather just iterate through the properties without having to hardcode them into the script, if it can be done.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  4. #4
    Senior Member
    Join Date
    Nov 2007
    Posts
    263
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Dump all object properties

    I don't know if it can be done (i.e. I don't know of a method to query an object and say 'Give me your list of properties'. ). On a good note, once you've written the code you won't have to touch it for a long long time since they are not likely to change.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:50 PM.

Copyright BetaSoft Inc.