Micro Focus QTP (UFT) Forums

Full Version: regular expression
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
Try:

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

still getting error message-says objects properties match an object currently displayed in your application....
Yes, I failed to notice the parenthesis the first time, try:

(inbox)$|inbox[\d\)\(]+
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.
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.
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.
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.
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 ..
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.
Pages: 1 2