Results 1 to 6 of 6
  1. #1

    Unable to select a node in WpfTreeView

    Hi All,

    I am using QTP 10 and when I try to Select a node within a WpfTreeView using:

    WpfWindow("Main App").WpfTreeView("treeView").Select ("Area1")

    I am getting an error that the Node cannot be found. I have tried this with several different nodes within the Tree View and QTP cant seem to see any of them.

    Any help is much appreciated.


  2. #2

  3. #3

    Re: Unable to select a node in WpfTreeView


    Yes, When I perform a record it records the tree nodes as all having the same name. The further into the expanded tree the nodes are they still have the same name. E.g. "Busy...;Busy...;Busy..." for a node 3 tiers deep, Very strange. If I do a select with the name "Busy..." it always selects the first node.

  4. #4

    Re: Unable to select a node in WpfTreeView

    i'm having similar problems when working with wpftreeview, have you found a solution if so please can you share it thanks.

  5. #5

    Re: Unable to select a node in WpfTreeView

    Did you try SendKeys method??
    A n i s h

    [My QTP Blog]

  6. #6

    Re: Unable to select a node in WpfTreeView

    I've had to hack together a function to do this, try the below (works for swfTreeView, I've taken out some extra code not relavent so I trust it hasn't broken it...). It's not pretty as it uses sendkeys and gettextlocation but so far it's holding up for me...

    Parameters are:
    objQTPClass - qtp object to perform against
    strItemToSelect - Part of the name of the item to select
    blnDoubleClick - set to true if you want to double click it

    So you would call it as follows:

    Call SwfTreeViewSelectItem(swfwindow("A").SwfTreeview(" B"),"Customer A",False)

    <font class="small">Code:</font><hr /><pre>
    Function SwfTreeViewSelectItem(objQTPClass, strItemToSelect, blnDoubleClick)
    Dim n
    Dim arrAllItems
    Dim strCurrentSelection
    Dim strTreeviewContents
    Dim WshShell
    Dim intLeft, intTop, intRight, intBottom, blnResult 'used for double click

    'Get a list of all of the treeview items
    strTreeviewContents = objQTPClass.GetContent
    'Split these into an array
    arrAllItems = split(strTreeviewContents,chr(10))

    'Set focus to the treeview &amp; ensure top node is selected
    call objQTPClass.Click(0,0)
    Set WshShell = CreateObject("WScript.Shell")

    'Now go through all of the items until a match is made
    For n = 0 to ubound(arrAllITems)
    If instr(arrAllITems(n),strItemToSelect) = 0 Then
    WshShell.SendKeys "{DOWN}"
    'We've found the item - it should also be selected in the treeview
    strCurrentSelection = objQTPClass.GetSelection

    'double check we've got the item
    If instr(strCurrentSelection,strItemToSelect) &gt; 0 then

    'Do we want to double click it?
    If blnDoubleClick Then
    'As the .Activate method does not work we have to hack our way around this.
    'The logic is: Use the GetTextLocation method to find the item and get it's co-ordinates
    'Once we know the co-ordinates, we can double click on the item
    intLeft = -1
    intTop = -1
    intRight = -1
    intBottom = -1
    blnResult = objQTPClass.GetTextLocation(strItemToSelect, intLeft, intTop, intRight, intBottom,False)
    If blnResult Then
    objQTPClass.DblClick intLeft,intTop
    reporter.ReportEvent micFail,"Failed to click item","Couldn't find text " &amp; strItemToSelect
    End If
    End If
    Exit Function
    reporter.ReportEvent micFail,"Failed to find item","Item wasn't selected: " &amp; strItemToSelect
    Exit Function
    End If
    End If

    'Item was not found in the treeviw
    reporter.ReportEvent micFail,"Failed to find item","Item was not in the treeview: " &amp; strItemToSelect
    End Function

    </pre><hr />



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:26 PM.

Copyright BetaSoft Inc.