hi friends,
What is Regular expression in QTP,why we use this and where we use this regular expression.
cheers,
Radhika.
hi friends,
What is Regular expression in QTP,why we use this and where we use this regular expression.
cheers,
Radhika.
Hi,
Please find the attachment of regular expressions in QTP
Regards,
Ganesh
Hi Jitesh,
I didn't mean that. Every one has to provide any information from one place or other. Even, you can find everything in QTP help. No need to look in any other place. But the thing is that, it may be difficult to some one to find help on a particular topic.
Regards,
Ganesh
Hi Radhika,
Regular expression is enables to quick test to identify the objects and text strings.we can use regular expression
1. Defining property values of an object in dialog boxes or programmatic description
2. parameterizing step
3. creating check points with varying values
for example you can use regular expression if you want create text check point on a date string.but displayed date changes according to the correct date. you have to use regular expression for your date and the check point checks the captured text strings matches the expected date format.
Regular expression is string that capture the complex search phase using special characters *.[],^......etc
Let us take yahoo! site as an example. Then the script will be something like:
===========================================================
Browser("Yahoo! Mail - The best").Page("Yahoo! Mail - The best").WebEdit("login").Set "TestUser"
Browser("Yahoo! Mail - The best").Page("Yahoo! Mail - The best").WebEdit("passwd").SetSecure "460205b87f0543"
Browser("Yahoo! Mail - The best").Page("Yahoo! Mail - The best").WebButton("Sign In").Click
Browser("Yahoo! Mail - The best").Page("Yahoo! Mail - TestUser@").Link("Addresses").Click
Browser("Yahoo! Mail - The best").Page("Yahoo! Address Book -").Link("Mail").Click
Browser("Yahoo! Mail - The best").Page("Yahoo! Mail - TestUser").Sync
===========================================================
Here the page title is continuously changing. but, all titles contain "Yahoo!"
When ever, you click on any tabs, i.e. (mail, compose, addresses, etc), the page title changes. but, still contains "Yahoo!" as part of the string. in this case, we can use regular expression (while using descriptive programming):
================================================================
Browser("Yahoo! Mail - The best").Page("ClassName:=Page", "title:=Yahoo.*").WebEdit("ClassName:=WebEdit", "Name:=login").Set "TestUser"
================================================================
Last edited by smganesh; 03-22-2007 at 12:57 AM.
regular expression is nothing but it combines alll the stages fro m which the string goes what i think. it actually encapsulates your entire string through the stages that passed the above exemples of smganesh is actually right way to implement your regular expression
Regular expression helps you identify dynamically changing objects, like some Nos, names, etc... where even the lenght changes
Regular expression is nothing but help us to smoothly run our script if there is any change in string which we can't even output.
If we can output that string it's always better to output the string in table and then where we have to verify that string then parametrized that with output column.
Regards,
Brijesh Jain
---------------------------------------------------------
Connect with me on Skype: jainbrijesh
Google Plus : jainbrijeshji
hi
Does anyone know if there are sample exam papers for the HP QuickTest
Professional Software - what kind of question they ask?
Thanks.
Jigar
Regular expression helps you identify dynamically changing objects, like some Nos, names, etc... where even the lenght changes
Thanks,
This is fine, can you please explain if is there any way to automate the dynamic links (which change very frequently on a web site) using Regex, if possible with an example?
llike when you search google with keyword "qtp", will get many search results, here I want to click on first 10 links and check whether I am getting the content or not, can this be done?
Hi,
Can anyone help me how to use regular expressions with more examples?
some times object properties will changing frequently based on input values ...(dynamic objects)
in that time we can use regular expressions.we can put manually in script or we can put in OR.
we have no of regular expressions.
.,*,[xy],[^xy],[x-y],$,?,|,
All right !! this inhancement will we do but where in the page. Shall we replace the all text with the modified line or any particular?
Hi,
You can see the following snippet for your undestanding.
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "'." & vbCRLF
Next
RegExpTest = RetStr
In my JAva Swing application, frame titles were changing dynamically. Suppose that, title is " - Screen [1]". The number in the title string changes in every iteration. And so, QTP was throwing 'Object not found exception' every iteration (In object repository object was record with the title = " - Screen [1]", but in runtime it was becoming " - Screen [2]"). In order to overcome this problem, i used regular expressions for title attibutes of JavaWindow objects. Let me explain steps,
1. Right click on JavaWindow object in Keyword View and select Object Properties, then Object Properties window is opened.
2. Select value of the title attribute and click <#>(configure the value) button at the right, then Value Configuration Options Dialog Window is opened
3. Check the Regular Expressions checkbox, then write your regular expression in the Constant text area and click OK button
In our example title name was " - Screen [1]" and let me explain how to make regular expression this title string:
In regular expressions we have to put '\' for special characters (for example [ or ] or - etc.). Use \s for space character, use \d indicating decimal value and use {a, b} where a is the min. number of digits and b is the max.
Then our regular expression becomes like this:
\s\-\sScreen\s\[\d{1,2}\] , here this is valid from " - Screen [0]" to " - Screen [99]"
You can find detailed information about the syntax in QTP help, "regular expression syntax" section.
i hope this is useful for you...
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "'." & vbCRLF
Next
Fax Order No .*