Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use regular Expression to find node item in swfTreeView
#1
Solved: 10 Years, 8 Months, 4 Weeks ago
Hello,

I'm new to QTP and evaluating it with Infragistics TestAdvantage at the moment. I have an application with an Infragistics UltraTree which is found by QTP as SwfTreeView. The selection of the nodes in this tree works fine with the select method like this:

Code:
SwfWindow("MyApp").SwfTreeView("myTree").Expand "\Root\Child1\Child2"

This method needs the text of the node to find it. As I can't exactly say what the Child2 nodes text will be (there might be some additional characters in front of "Child2") I wanted to use regular expressions to find the node, is that possible? The following code didn't work for me:

Code:
SwfWindow("MyApp").SwfTreeView("myTree").Expand"\Root\Child1\*Child2"

Is it even possible to use regular expressions in this case?

Is there another possibility to find a node in a tree by a regular expression? Or is it possible to loop through all nodes and compare their text to a given one?

I also tried to get a String with all the nodes using:

Code:
SwfWindow("MyApp").SwfTreeView("myTree").GetContent

and then created a RegExp object to look for the pattern in this string but with no success.

In some thread I read about a check box in QTP to enable the regular expression usage but I can't find it in the qtp application. Do I have to enable it before it works correctly? I'm a bit puzzled about that now.

Any hints about that appreciated.

Regards

Simone
Reply
#2
Solved: 10 Years, 8 Months, 4 Weeks ago
I was able to solve the problem getting the list with all the nodes using GetContent and then looking for the regular expression. Unfortunately my expression was not quite correct. Now it works and I also found the check box that I read about in several posts. This forum is really useful, thanks.

Regards

Simone
Reply
#3
Solved: 10 Years, 8 Months, 4 Weeks ago
good that you got the answer...
You can put the solution here so that others having similar problem can benefit from it.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#4
Solved: 10 Years, 8 Months, 4 Weeks ago
After having created the RegExp object and set the pattern to search for, get all the recently visible tree nodes using

Code:
myNodes = SwfWindow("MyApp").SwfTreeView("myTree").GetContent
Then perform the search for this expression on the myNodes string. In the nodes of my tree were some special characters which I did not mark as literal what caused the search to fail.

Code:
Set NodeMatches = myRegEx.Execute(myNodes)

In the NodeMatches are the found matches of the search. Pick one of the matches (if there are more) and you have the full path of a node which can be used to do the expand operation.

The check box to enable regular expressions I read about, has nothing to do with this case. It can be found in the Object Repository and can be used to enable regular expressions to identify the controls. After clicking the button to parameterize a controls property, the check box is located in the upcoming dialog window.

Hope this helps someone.

Regards,

Simone
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Any digit in xpath path using Regular expression Priyam 1 3,262 10-05-2016, 11:05 AM
Last Post: Ankur
  Regular expression to read two words in lowercase, uppercase and with and without spa sarahq49 1 3,209 04-09-2015, 01:56 AM
Last Post: sarahq49
  Regular expression and script optimisation Padmavathy 1 3,614 03-30-2015, 11:46 AM
Last Post: supputuri
  Regular expression in descriptive programming testernc 1 16,396 12-08-2014, 06:38 PM
Last Post: anshika.agarwal
  need a regular expression. anu05446 0 3,026 11-26-2014, 03:00 PM
Last Post: anu05446

Forum Jump:


Users browsing this thread: 1 Guest(s)