Micro Focus QTP (UFT) Forums
How Can I Use Regular Expression on Tree View Node Object? - 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: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: How Can I Use Regular Expression on Tree View Node Object? (/Thread-How-Can-I-Use-Regular-Expression-on-Tree-View-Node-Object)



How Can I Use Regular Expression on Tree View Node Object? - ajamaljackson - 12-22-2011

I'm new to QTP and have been doing very well at figuring things out on my own. However, I have a problem I can't figure out and none of the solutions I'm finding and trying are working. Here's my problem:

I have a script which has a Tree View Node which only displays as "_treeview" in the Object Repository. However, I wrote this code to display the child nodes not displaying in the OR:
**************************************
Code:
myNodes = SwfWindow("New Loan").SwfTreeView("_treeView").GetContent
MsgBox myNodes
**************************************
It worked and all the child nodes I was looking for showed up in the MsgBox, including the ones I want to put a Regular Expression On (SEE ATTACHMENT):

Example:
Loan;Contacts;Mister Software Tester;Personal
Loan;Contacts;Mister Software Tester;Employer
etc.

The name (Mister Software Tester) changes on each iteration. Could someone please tell me how to write a Regular Expression to identify this object in the script, eventhough the name (Mister Software Tester) is dynamic. For instance on the next iteration the object name may be:

Loan;Contacts;Misses Tester Lady;Personal
Loan;Contacts;Misses Tester Lady;Personal

Please Help.

Thank you.


RE: How Can I Use Regular Expression on Tree View Node Object? - Ankesh - 12-26-2011

Hi,

Where do you want to use the regular expression - Code or Object repository?

Object Repository
------------------
Code:
Loan;Contacts;[a-zA-z];[a-zA-z]

Code
------
Code:
Set RegEx = CreateObject("VBScript.RegExp")

RegEx.Pattern ="^Loan;Contacts;[a-zA-Z];[a-zA-Z]$"

result=RegEx.Test(strText)
If result=True Then
msgbox "Pass"
Else
msgbox "Fail"
End If

Set RegEx=Nothing

Plz check if this helps.

Regards,
Ankesh


RE: How Can I Use Regular Expression on Tree View Node Object? - test - 12-26-2011

Hi

thanks Ankesh