Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular Expression for a List Value
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
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.
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
I Think "[0-9]" OR "\d" will work in place of digit you are using.
Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
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?
Reply
#4
Solved: 10 Years, 8 Months, 3 Weeks ago
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.
Reply
#5
Solved: 10 Years, 8 Months, 3 Weeks ago
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.
Reply
#6
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Reply
#7
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Reply
#8
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Reply
#9
Solved: 10 Years, 8 Months, 3 Weeks ago
I Think "[0-9]" OR "\d" will work in place of digit you are using.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Any digit in xpath path using Regular expression Priyam 1 3,254 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,200 04-09-2015, 01:56 AM
Last Post: sarahq49
  Regular expression and script optimisation Padmavathy 1 3,613 03-30-2015, 11:46 AM
Last Post: supputuri
  Regular expression in descriptive programming testernc 1 16,394 12-08-2014, 06:38 PM
Last Post: anshika.agarwal
  need a regular expression. anu05446 0 3,012 11-26-2014, 03:00 PM
Last Post: anu05446

Forum Jump:


Users browsing this thread: 1 Guest(s)