Micro Focus QTP (UFT) Forums
Regular Expression for a List Value - 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: Regular Expression for a List Value (/Thread-Regular-Expression-for-a-List-Value)



Regular Expression for a List Value - Reaper - 10-12-2010

I am creating a QTP test script on a .Net application.

When recording similiar to the below is recorded:

Code:
SwfWindow("My Application".SwfWindow("Work Queue").SwfTreeView("WorkType").Select "Tasks(8);My Tasks(3)"

This window is a work queue, which means the "Tasks(8);My Tasks(3)" values in brackets could change from 8/3 to any number depending upon the work items in the queue.

I am unable to open the list to do a count of rows, since I first need to select the required value

Is their anyway to may the number in the brackets as a regular expression? - even though this is the actual data, rather than the object.

The only other solution I can come up with is to do a loop and search if each value exists, but this seems very crude, so would prefer a better solution if it's available.

Thanks in advance for any help in coming up with a solution for this.


RE: Regular Expression for a List Value - KavitaPriyaCR - 10-12-2010

I Think "[0-9]" OR "\d" will work in place of digit you are using.


RE: Regular Expression for a List Value - Reaper - 10-12-2010

Kavita, thanks for your assistance. I've tried your possible solution, but this does not seem to work in this instance. I guessing turning an object to a regular expression is different than the actual data item part.

Any other ideas?


RE: Regular Expression for a List Value - KavitaPriyaCR - 10-12-2010

Reaper, You can try with taking some variable variable i guess, because as it seems it is a weblist, we can iterate it with variable as we do in looping.
Example:
Code:
i=3   ' Do as per your reqt
namei=SwfWindow("My Application".SwfWindow("Work Queue").SwfTreeView("WorkType").GetItem(i)
SwfWindow("My Application".SwfWindow("Work Queue").SwfTreeView("WorkType").Select namei

Sorry if i am wrong, i have not worked with .net projects.


RE: Regular Expression for a List Value - Reaper - 10-12-2010

Thanks for your further assistance Kavita, it's greatly appreciated. I think your proposed soloution would be like the loop I did think of, but I would like to avoid this as a solution if possible, as it seems to be very crude to go through mulitple values looking for one that matches.

I guess if you haven't worked with .net objects, the simplest way to consider this is - think of a drop down menu with a list of data items. All items are say fruit names, eg. Banana, Apple, Grapes etc. But for each item, their is also a number in brackets which represents the amount available, so your list could be "Apple (3)", "Banana (17)", "Grapes (1)". This is the list currently, but tomorrow, the values in brackets could be something else, i.e. go up or down or be the same. So I need to code to select say "Apple" and ignore whatever the number is - hence the regular expression route for this solution.

I understand regular expression for the objects, but I am trying to make it regular for the data items which I don't even know if it is possible being a data driven application.


RE: Regular Expression for a List Value - Jyobtech - 10-13-2010

Hi ,
Can you try this,It may useful to you

Code:
SwfWindow("My Application".SwfWindow("Work Queue").SwfTreeView("WorkType").Select "RegExp:=Tasks.*;RegExp:=My Tasks.*"

Regards,
Jyo


RE: Regular Expression for a List Value - ngocvo3103 - 11-16-2010

Hi Reaper,

Can you try with this regular expression: ^My Tasks(\(\d+\))?$
This Regex will match with:
- My Tasks
- My Tasks(0)
- My Tasks(5)
- My Tasks(99999999999)
- ...

Hope to hear you soon
Ngoc Vo


RE: Regular Expression for a List Value - vinod_qtp - 12-29-2010

Hi N,
Thanks for the solution, i have a same problem with Java tab and tried with your RG suggested by you, but prompts the same error.

Recorded Code
Code:
JavaWindow("Trades").JavaTab("Active: 0").Select "Orders([b]9[/b])
where 9 is the dynamic number from 0 to 9 at each iteration.

Tried with Code
Code:
JavaWindow("Trades").JavaTab("Active: 0").Select "Orders(\(\d+\))?$"

Please let me know any solution for this.

Thanks


RE: Regular Expression for a List Value - Ruprecht - 04-12-2011

I Think "[0-9]" OR "\d" will work in place of digit you are using.