QTP: Regular expressions and Descriptive Programming

I am using some of the code I listed earlier in my blog to open and get the hwnd of some browser/page objects. However, one of the other automation engineers found an issue with my code. Apparently, the code had trouble opening a url like http://groups.google.com/grphp?. So, I began to work on it. QTP was returning the ever-useful “General Error“ error, so I had to sleuth this out for myself. I am using this construct in my code to get at the handle:

If Browser(“hwnd:=“ & strBrowser).Page(“url:=“ & oIE.Document.url).Exist(0) then

     strPage = Browser(“hwnd:=“ & strBrowser).Page(“url:=“ & oIE.Document.url).GetROProperty(“hwnd“)

End If

Now, the co-worker was getting the aforementioned General Error (i.e., I am broke and not smart enough to tell you why) on the line inside the If. So, descriptive programming worked fine to get in there. However, when it got to the line inside, it didn't. I added some code to place a “\“ in front of the ? the co-worker passed (to indicate that the ? should be treated literally), and it works fine. I modified the code I now use to look for this issue and correct it without direction.

My only issue is: why the heck did it work fine on the Exist line, but not the GetROProperty line?

Lesson learned: be mindful of regular expressions in your descriptive programming.

 

Join me at:

SC Code Camp 2.0

 

posted @ Wednesday, May 10, 2006 2:40 PM

Print

Comments on this entry:

# re: QTP: Regular expressions and Descriptive Programming

Left by Balaji at 5/17/2006 2:52 AM
Gravatar
This is becaus descriptive programming does not work properly with check points... even i am not sure how of the solution for this

# re: QTP: Regular expressions and Descriptive Programming

Left by Theo Moore at 5/17/2006 4:11 AM
Gravatar
Fortunately, placing the "\" in the expression (i.e., "url:=http://groups.google.com/grphp\?" ) works fine. MIC can't seem to give me an explanation of why, though they agree that this difference in behaviour makes little sense.

Theo

# re: QTP: Regular expressions and Descriptive Programming

Left by arpita at 8/25/2006 5:53 AM
Gravatar
Hi

I want to use regulare expression for a frame name identification in Object repositor which can chage in this order:
best *** ways to do
eg:
best hkj eretrt ertert ways to do
best sd ways to do
best rer wer ways to do

i want to use regular expression to match
*** where it can be a single word or more than 1 words.

any suggestions?

where ** can be

# re: QTP: Regular expressions and Descriptive Programming

Left by Unknown at 12/13/2006 11:04 AM
Gravatar
Try out this...
.*ways to do.*

Thats how we use it in our project.

# re: QTP: Regular expressions and Descriptive Programming

Left by milind bhatkar at 12/26/2006 6:54 AM
Gravatar
Try this

strr = ".*"&"ways to do"&".*"
browser().page().frame().object.settoproperty"text",strr

while doing this make sure to change text property of object to regular expression.

# re: QTP: Regular expressions and Descriptive Programming

Left by seethapathi at 5/8/2007 6:23 AM
Gravatar
how can i check the email address using regular expression?

# re: QTP: Regular expressions and Descriptive Programming

Left by chaitanya at 5/20/2007 8:54 AM
Gravatar
I need How to use regular expression in Descriptive Programme in QTP

# Doubt on using regular expression at run time

Left by Prabeen Pradhan at 8/29/2007 3:53 AM
Gravatar
When we use regular expression for a particular property, say "text" property, we go to object repository and check the regular expression check box (qtp 9.0 and above). Then we use the settoproperty method for that particular property.

My query is that, is there any way to check the regular expression checkbox in object repository for a particular property at run time if it is not checked in object repository ?

# Doubt on using regular expression at run time

Left by Prabeen Pradhan at 8/29/2007 3:53 AM
Gravatar
When we use regular expression for a particular property, say "text" property, we go to object repository and check the regular expression check box (qtp 9.0 and above). Then we use the settoproperty method for that particular property.

My query is that, is there any way to check the regular expression checkbox in object repository for a particular property at run time if it is not checked in object repository ?

# re: QTP: Regular expressions and Descriptive Programming

Left by anji at 9/3/2007 7:17 AM
Gravatar

("title:=WCO 2.2.2 Related Customs Duties.*")

Hi Arpita,

you can use Regular Expression like that here in the last i used as (.* ) by using like u can match titels or any words

# re: QTP: Regular expressions and Descriptive Programming

Left by anji at 9/3/2007 7:17 AM
Gravatar

("title:=WCO 2.2.2 Related Customs Duties.*")

Hi Arpita,

you can use Regular Expression like that here in the last i used as (.* ) by using like u can match titels or any words

# re: QTP: Regular expressions and Descriptive Programming

Left by anji at 9/3/2007 7:17 AM
Gravatar

("title:=WCO 2.2.2 Related Customs Duties.*")

Hi Arpita,

you can use Regular Expression like that here in the last i used as (.* ) by using like u can match titels or any words

# re: QTP: Regular expressions and Descriptive Programming

Left by anji at 9/3/2007 7:17 AM
Gravatar

("title:=WCO 2.2.2 Related Customs Duties.*")

Hi Arpita,

you can use Regular Expression like that here in the last i used as (.* ) by using like u can match titels or any words

# re: QTP: Regular expressions and Descriptive Programming

Left by anji at 9/3/2007 7:17 AM
Gravatar

("title:=WCO 2.2.2 Related Customs Duties.*")

Hi Arpita,

you can use Regular Expression like that here in the last i used as (.* ) by using like u can match titels or any words

# re: QTP: Regular expressions and Descriptive Programming

Left by Sudhanshu at 9/19/2007 1:53 PM
Gravatar
I m recording a script n that time it takes generates code as
"Browser("Exact e-Synergy - msudhanshu").Page("Exact e-Synergy - msudhanshu").Frame("Products").Link("HRM").Click"
I want that browser should not be static , if next time the value of browser hase been changed i.e. "Exact abc" and i play the same script it should start the application again accepting the changed browser title.. How to use regex here or any other solution.. Please reply ASAP.. Thanks.

# re: QTP: Regular expressions and Descriptive Programming

Left by Kirubakaran at 11/27/2007 4:07 AM
Gravatar
Hi folks,
can anybody say the usage of SetTOProperty with an example?

# re: QTP: Regular expressions and Descriptive Programming

Left by Mundu at 12/5/2007 2:25 AM
Gravatar
In a treecontrol I want to select a mode which has its initial 5 characters stable and the remain keep varying. Is there any way in which i can check only the first 5 characters of that node and ignore the rest?
e.g A buddy in yahoo contact list "Venkat(busy)" i want a way to ignore the status part of the buddy name and identify that buddy using the constant part even if the keeps changing. Currently my script fails if he changes his status...plz help

# re: QTP: Regular expressions and Descriptive Programming

Left by Mundu at 12/5/2007 2:25 AM
Gravatar
In a treecontrol I want to select a mode which has its initial 5 characters stable and the remain keep varying. Is there any way in which i can check only the first 5 characters of that node and ignore the rest?
e.g A buddy in yahoo contact list "Venkat(busy)" i want a way to ignore the status part of the buddy name and identify that buddy using the constant part even if the keeps changing. Currently my script fails if he changes his status...plz help

# re: QTP: Regular expressions and Descriptive Programming

Left by suresh at 12/11/2007 4:29 AM
Gravatar
HAI FRIENDS I AM FRESHER IN QTP AND I WANT TO JOIN IN UR BLOGS

# re: QTP: Regular expressions and Descriptive Programming

Left by suresh at 12/11/2007 4:29 AM
Gravatar
HAI FRIENDS I AM FRESHER IN QTP AND I WANT TO JOIN IN UR BLOGS

# re: QTP: Regular expressions

Left by siva at 1/19/2008 4:01 AM
Gravatar
hi
i am fresher in qtp.
i am getting this error "cannot identify the object "fax order no.273" (of class dialog).verify that this object's properties match an object currently displayed in your application.
can any one give me the solution for this error

# re: QTP: Regular expressions and Descriptive Programming

Left by vxcssdfsdfsfsfs at 2/4/2008 5:08 AM
Gravatar
cxvxvcvxcvwerwerwerwerdfsdf
s dfsfdfsdfsdfsd ds

# re: QTP: Regular expressions and Descriptive Programming

Left by vxcssdfsdfsfsfs at 2/4/2008 5:08 AM
Gravatar
cxvxvcvxcvwerwerwerwerdfsdf
s dfsfdfsdfsdfsd ds

# re: QTP: Regular expressions and Descriptive Programming

Left by sameer at 2/20/2008 12:33 AM
Gravatar
how to open the google page with out recording option.
i need to write the descriptive program

# re: QTP: Regular expressions and Descriptive Programming

Left by mahendar at 3/6/2008 3:55 AM
Gravatar
hi sameer.
u can type script as systemutil.run "http://www.google.co.in/"

u wil get google page

# re: QTP: Regular expressions and Descriptive Programming

Left by pari at 5/2/2008 1:09 PM
Gravatar
Hi sudhanshu,

Regarding your question about changing Browser name, you can use regular expression to match the browser name as "Exact .*"
Comments have been closed on this topic.
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910