Micro Focus QTP (UFT) Forums
regular expression - 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 (/Thread-regular-expression--3858)

Pages: 1 2


regular expression - bangla123 - 10-06-2010

Hi,

I am doing regression testing. When i record the web application, i see in inbox(6). I clicked on inbox(6). Then i run the script, it fails on inbox(6) step because inbox(6) became inbox in web application.

To solve it, i put regular expression statement as follows: inbox\([0-100]\). it fails. If i have inbox(0) or inbox(1),.. it passes. but it fails because web application shows: inbox. No number next to it.

Someone pls help me. Thanks.

safiullah12@hotmail.com


RE: regular expression - jsknight1969 - 10-06-2010

Try:

inbox[\d]?


RE: regular expression - bangla123 - 10-06-2010

i tried inbox[\s]
inbox[\d]

still getting error message-says objects properties match an object currently displayed in your application....


RE: regular expression - jsknight1969 - 10-06-2010

Yes, I failed to notice the parenthesis the first time, try:

(inbox)$|inbox[\d\)\(]+


RE: regular expression - bangla123 - 10-06-2010

when i go to object properties, i see text, innerhtml, and html tag. I did reg expression only for text. Do i need to do reg expression for innerhtml too? Innerhtml shows:<SPAN class=caption....inbox...6..,/SPAN>

thx.


RE: regular expression - jsknight1969 - 10-06-2010

You can use any of the values. I recommend which ever property is shorter and the most unique so the RegExp is less complex. You can use the html tag and descriptive programming to limit the number of objects to view as well.
Code:
Browser().Page().Link("micclass:=Link,html tag:=a,text:=(inbox)$|inbox[\d\)\(]+").Click

That should only click on a Link (<a> tag) with text of inbox or inbox(x). Shouldn't be many of those on the page.


RE: regular expression - bangla123 - 10-06-2010

Now I am doing for Junk folder. I had 64 emails in junk folder when i recorded. I deleted all. Before junk folder looked like this: Junk(64). Now it looks like: Junk
object properties shows:
Code:
text =  (Junk) $|Junk[\d\)\(]+
innerhtml = inline">(<SPAN>64</SPAN>)</SPAN></SPAN>

Cant pass the step. Thanks in advance.


RE: regular expression - jsknight1969 - 10-06-2010

Should work. I noticed the span tags in your Junk description. I wouldn't think that would come over as part of the text, but if it is, then the expression needs to be adapted to allow it. You can try using:

Code:
msgbox Browser().Page().Link(your link).TOProperty("Text")

That will display the text for the link so you can verify any additional text needed for your expression.

Also check for a space between (Junk) and $. Your post shows one.
I would really try to use the HTML ID tag instead of the text. You are obviously doing some sort of email application and the link text can change, but the HTML ID should always be the same. View the source of the page and see if it has an ID you can use.


RE: regular expression - bangla123 - 10-06-2010

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("micclass:=Link,html tag:=a,text:=(Junk)$|Junk[\d\)\(]+").Click
this is i wrote. I get error saying "object does not support this property.... "

let me try using msgbox ..


RE: regular expression - jsknight1969 - 10-06-2010

It's been my experience that when using multiple descriptors, it better to use a Description object.

Code:
dim desc, link
set desc = Description.Create()
desc("html tag").value = "a"
desc("micclass").value = "Link"
desc("text").value = "(Junk)$|Junk[\d\)\(]+"
Browser().Page().Link(desc).Click

Should work the same either way though.