Micro Focus QTP (UFT) Forums
Find specific records in a SwfTreeView on different node levels - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Find specific records in a SwfTreeView on different node levels (/Thread-Find-specific-records-in-a-SwfTreeView-on-different-node-levels)



Find specific records in a SwfTreeView on different node levels - lotos - 10-06-2017

Hi guys, I have some hard time figuring out how to select specific items in a dynamic SwfTreeView. So next are the details:

The tree looks like here:
[attachment=1427]

- every element inside it has a checkbox (all parents and childs)
- the child items are dynamically generated (sometimes there could be no childs under some of the parents)
- parent items are always same
- 1st & 2nd parents have the Expand/Collapse function as they have child items (but might not have sometimes)
- 3rd parent does not have an Expand/Collapse functionality as it has no child elements (but might have sometimes)

The issue is that I need to build a function which has 2 input parameters (e.g. docType [the parents] & docName [the childs]).
Now I need the function to be smart enough in order to handle next cases (also the case when a parent node does not have childs - it should be ignored & reported and if randomizer was used to generate it then re-do (randomize so only a correct/existent parent is chosen and one which actually has childs):

Code:
Public Function Fn_PrintDocuments(docType, docName)
    
    '1. case where both parameters have a values
    If docType <> "" and docName <> "" Then
        'find docType & docName
        
        'check the item
        
    '2. case where docType parameters has no value but docName has a value
    ElseIf docType = "" and docName <> "" Then
        'find docName
        
        'retrieve it's docType
        
        'check the item
        
    '3. case where docType parameters has a value but docName has no value
    ElseIf docType <> "" and docName = "" Then
        'find docType
        
        'randmomize docName's of actual docType
        
        'check the random docType
        
    '4. case where both parameters have no values
    ElseIf docType = "" and docName = "" Then
        'randomize docType
        
        'find the docNames of randomized docType
        
        'randomize docNames
        
        'check randomized docName of randomized docType
        
    '*. not sure if there is another case - added the handler just in case something comes up later
    Else
        Reporter.ReportEvent micWarning, "'Fn_PrintFITDocumentOnInformationScr' - another case found", ""
    End If
 
End Function

Suggestions? I've been fighting it the hole day and found different ways online but neither worked for me as I could not fully complete the work.

Thank you.