Tuesday, 26 November 2013

When to use descriptive Programming in QTP

Descriptive programming in QTP is used in below scenarios.

  1. Whenever the objects in the applications change quite often.
  2. When it is not feasible to store the objects in OR. For example all links on the page
  3. When same object exists in the different pages/windows of the application.

There are 2 types of description programming.

  1. Static Descriptive programming
  2. Dynamic Descriptive programming

Static Descriptive programming Example - 

 Browser("index:=0").page("title:=Google").webedit("name:=q").set "xyz"

Dynamic Descriptive programming Example - 
'Find all edit boxes on google page using descriptive programming
Set descriptionObject = Description.Create()
descriptionObject("micclass").value = "webedit"
descriptionObject("outerhtml").value = ".*input.*"
descriptionObject("outerhtml").regularexpression = true

set col = Browser("index:=0").page("title:=Google").childobjects(descriptionObject)

print "Total edit boxes on the page"  & col.count

For i=0 to col.count-1
print col(i).getROProperty("outerhtml")

Next

You may also like below topics on descriptive programming in QTP.

  1. Using regular expressions in QTP.
  2. How to by pass OR in QTP.
  3. Description object in QTP.


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Error Handling in QTP

There are 2 ways in which we can handle errors in QTP.

  1. Err object.
  2. Recovery Scenarios.
Sample code to handle the error is given below

If err.number <> 0 Then
print err.description
else
print "there  was no error in above statement"
end if 


Whenever any error occurs in the script, We get the message window with detailed description of the error.

But when we are executing the scripts, we do not want this message box to appear to come as this will halt the execution of the script.

To prevent message box from appearing, we use below statement above the block of code.

On error resume next
----------
----------
more statements

With On error resume next in place, QTP script runs even though error exists in the code. We can capture those errors using Err object as stated earlier.

When you are debugging the scripts, you should not use On error resume next statement as it will suppress the errors and you will not be able to figure out the issue in your script.

You may also like below topics on error handling in QTP.

  1. On error resume next in QTP
  2. Err.Number in QTP

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to take a screenshot in QTP?

In QTP, when we execute the test cases, test cases may fail due to valid / invalid defects. They may also fail due to script issues or any other issues like network failure.

After the test execution ends, We only have the html reports or QTP results with us which does not give clear picture about the status of application. To solve this problem we can take the snapshot of the application when any test step fails.

Example - Below code will take the screen shot. You can insert this code anywhere you want to take the screen shot.

Window("xyz").CaptureBitmap "c:\screenshots\abc.png",True
'In above code we are storing the png image file to c drive location. Second parameter tells whether to overwrite existing file.

Thus you can use capturebitmap method of any object to take the screen shot.


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Sunday, 24 November 2013

How to add standard checkpoints in QTP

Checkpoints are used to verify the property values with expected ones. If they match checkpoints pass else they fail.

You can add standard checkpoint by right clicking the statement and then selecting the insert standard checkpoint menu.

Sample checkpoint window is shown here..



Browser("Google").Page("Google").WebEdit("q").Set "salunke"

Browser("Google").Page("Google").WebEdit("q").Check CheckPoint("q_2")

Browser("Google").Page("Google").WebEdit("q").Output CheckPoint("q")

Browser("Google").Page("Google").WebButton("Google Search").Click

Results window showing the checkpoint status


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to create output value in QTP?

Output value is used to store the data generated by application while execution is going on for later use.
For example - Suppose after you place the order, order id is generated. So you can store this order id in output value so that you can use this value for later use ..say to fax the order

To add the output value you have right click on the statement after which you want to add output value.
Once you right click you will find the output value properties window like the one below.


You can check the property values that you want to store in the output value. You can also specify where you want to store the values (datatable or environment)

Browser("Google").Page("Google").WebEdit("q").Set "salunke"

Browser("Google").Page("Google").WebEdit("q").Output CheckPoint("q")

Browser("Google").Page("Google").WebButton("Google Search").Click




When You execute the script, in results you can find the output values.

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What is the use of start transaction in QTP?

In QTP you will find one option called start/end transaction.

Transactions in qtp  are used to calculate the time required to perform the given operation
You can start the transaction using below syntax

Example on Transactions in QTP

Services.StartTransaction "transfer"
a = 2
b = a+2
'do some more opertions

Services.EndTransaction "transfer"

Once the transaction is complete, total time required to execute the transaction is logged in the QTP results automatically.




Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Dictionary Object in QTP with Example

Dictionary object is used to store the data in key-item pairs in qtp.

A Dictionary object is just like an associative array.
It stores the data in the form of key-item pairs.
Each key has some data item associated with it.
Key can be integer or string format.
Data item can be integer or string or array of variants. It may contain other dictionary itself.

Methods of Dictionary Object

Add -------> Adds new key-item pair in the dictionary object
Exists ----> returns true if the given key exists in the dictionary object
Items -----> returns the array containing all items in the dictionary object
Keys ------> returns the array containing all keys in the dictionary object
Remove ----> removes the key-item pair with given key from the dictionary object
RemoveAll -> removes all key-item pairs from the dictionary object

Properties of Dictionary Object

Count--------> returns the total number of keys in the dictionary object
Item---------> assigns or returns the item value with given key from the dictionary object
Key----------> sets the new key value for the given key
CompareMode -> assigns or returns the comparison mode for comparing string keys in a Dictionary object.

Example with dictionary object in QTP

'create new dictionary object
Set dictionaryObject = CreateObject("Scripting.Dictionary")

'add some key-item pairs
dictionaryObject.Add "1", "Sagar"  
dictionaryObject.Add "2", "Amol"
dictionaryObject.Add "3", "Ganesh"

'Display data in the dictionary
for each k in dictionaryObject.keys

print k & " - " & dictionaryObject.item(k)

next


'Remove the key-item pair with key = 1  from the dictionary object
dictionaryObject.Remove("1")

'Remove all key-item pairs from the dictionary object
dictionaryObject.RemoveAll

'Release the object
Set dictionaryObject = nothing

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Filesystemobject methods in QTP

Filesystemobject is used to access the computer's file system in QTP. You can read, edit, delete files using this object. You can also create/ delete folders using this object in QTP.

Most important methods of Filesystemobject

CopyFile Method ----------->copies file from one location to other with option to overwrite existing file
CopyFolder Method---------->copies folder and its contents from one location to other with option to overwrite existing folder
CreateFolder Method-------->creates a new folder. If the folder already exists, error occurs. So before creating a folder, check for its existance
CreateTextFile Method------>creates a new file and returns the textstream object with option to overwrite and format mode (Ascii or unicode)
DeleteFile Method---------->deletes the specified file. Error occurs if the given file does not exist
DeleteFolder Method-------->deletes the specified folder. Error occurs if the given folder does not exist
DriveExists Method--------->returns true if the given drive exists in the system else returns false
FileExists Method---------->returns true if the given file exists in the system else returns false
FolderExists Method-------->returns true if the given folder exists in the system else returns false
GetDrive Method------------>returns drive object for the given drive
GetFile Method------------->returns file object for the given file
GetFolder Method----------->returns folder object for the given folder
MoveFile Method------------>moves file from one location to another
MoveFolder Method---------->moves folder and it's contents from one location to another
OpenTextFile Method-------->opens the text file and returns the textstream object with option of iomode, create new file and format mode(ascii/unicode)

GetDriveName Method-------->gets the drive name for the given path
GetFileName Method--------->gets the file name (last component ) for the given path
GetExtensionName Method---->gets the extension for the given path like txt, mp3 etc
GetAbsolutePathName Method->gets the complete path for the given relative/absolute path
GetBaseName Method--------->gets the name of file (last component) excluding extension
GetParentFolderName Method->Gets the name of parent folder


Filesystemobject has only one property 
Drives Property------------>returns the collection of the drives objects in the system

Examples on filesystem object

   Set fso = CreateObject("Scripting.FileSystemObject")

   print fso.GetdriveName("c:\sagar\bl\metachara.txt")
   'output -  c:
   print fso.GetAbsolutePathName("c:\sagar\bl\metachara.txt")
   'output - C:\sagar\bl\metachara.txt
   print fso.GetExtensionName("c:\sagar\bl\metachara.txt")
   'output - txt
   print fso.GetBaseName("c:\sagar\bl\metachara.txt")
   'output - metachara
   print fso.GetFileName("c:\sagar\bl")
   'output - bl

You may also like below topics on file handling in QTP.

  1. Create a text file in QTP.
  2. Delete a folder in QTP
  3. Delete an Excel file in QTP
  4. Create a folder in QTP.
  5. Rename a file in QTP.
  6. Append contents to text file in QTP.
  7. Copy text file in QTP.
  8. Write data to text file in QTP.
  9. Check if file exists in QTP.
  10. Copy folder in QTP.
  11. Read a text file in QTP.
  12. Check if folder exists in QTP.
  13. Delete text file in QTP.

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Test Settings in QTP

Test settings is very important part of the QTP test. You can open the test settings from the file sub menu.
You will find below sections in test settings window.

1. Properties Settings:
In properties section you will find the location of the test and add-ins associated with the test.


2. Run Settings:
In run section you will find below settings.

  1. Data table iterations
  2. When error occurs - what to do
  3. Object Synchronization timeout




3. Resources Settings:
In resources section you will be able to see/edit the associated function libraries of the test.




4. Parameters Settings:
In parameters section you will specify the input and ouptu parameters.

You can access the parameters using script as mentioned below.

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
Set pDefColl = qtApp.Test.ParameterDefinitions
Set rtParams = pDefColl.GetParameters() ' Retrieve the Parameters collection defined for the test.
Set rtParam = rtParams.Item("sagar") ' Retrieve a specific parameter.
print rtParam.value



5. Environment Settings:
In Environment section you can view built - in and user defined global variables. You can also create new user defined variables here.




6. Web Settings:
In web section you can specify the browser navigation timeout.




7. Recovery Settings:
In recovery section you will be able to add and activate/deactivate  new recovery scenarios to the test.
You can also view the properties of the scenarios.


8. Local System Monitor Settings:
In this section you can monitor the various properties of the system like memory usage, cpu usage by given application during test execution.




You may also like below topics on test settings.

  1. How to associate library files in QTP.
  2. Folder structure in QTP
  3. Types of environment variables in QTP.
  4. How to get System Environment Variables.
  5. How to load ini file in QTP


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Recovery Scenario in QTP with Example

Recovery scenarios are used to handle the unexpected events that might occur while test execution is going on by QTP.

Please find below the steps that have to be followed to create the recovery scenario in QTP.

First of all You have to open the recovery scenario manager.  In resources menu you will find  recovery scenario manager option. Click on that and you will get to see below window.

Step1: Open Recovery  Scenario Manager.
Using recovery scenario manager you can create new recovery scenarios and store it in a file with .qrs extension.
One qrs file may contain multiple recovery scenarios.

To create new recovery scenario, click on the button circled with red color. It will open recovery scenario wizard.


Step 2: Open Recovery  Scenario Wizard.
Recovery scenario wizard shows the steps involved in creating the recovery scenario. Click on Next

Step 3: Select Trigger Event.
There are 4 types of the trigger events.
  1. Pop up window
  2. Object State
  3. Test Run Error
  4. Application Crash



Step 4: Specify the trigger Details.
In this step you have to specify more details about the trigger. For example if you selected pop up window in trigger event above, you will have to provide the title or text of the pop up as shown below.



Step 5: Recovery Operation.
After specifying the trigger event, you have to provide the recovery operation. There are 4 types of the recovery operations.
  1. Keyboard or mouse operation
  2. Close application process
  3. Function Call
  4. Restart Microsoft Windows





 Step 6: Post Recovery  Operation.
In Post Recovery You can tell what step should be executed after recovery is done by QTP.


 Step 7: Name  the Recovery  Scenario.
You have to give the name to recovery scenario in this step

 Step 8: Finishing the recovery scenario.
This is last step. You can add this scenario to current test in this step.



 Once you click finish recovery scenario manager window will be shown where you can save the qrs file.

Please note that to activate recovery scenario, you have to go to test settings.

You may also like below topics on Recovery Scenarios.
  1. How to Use Recovery Scenario Manager
  2. qrs file in QTP
  3. How to handle pop ups in QTP


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Thursday, 21 November 2013

How to use Regular Expression Evaluator in QTP 11

In QTP 11,  Regular Expression Evaluator is a new tool added by HP. This helps us test the regular expressions on sample input strings. This is very useful tool.

To open Regular Expression Evaluator, you have to click on tools menu. There you will find option for Regular Expression Evaluator. Click on it.

  1. Once Regular Expression Evaluator is open, you can enter the Regular Expression inside the first edit box circled in red
  2. In large text box, you can enter sample text string that you want to test.
  3. Then you can click on the highlight button.
If the match is found, that is colored in yellow. It also shows you total number of matches found at the bottom of the Regular Expression Evaluator window.

Once you are sure that Regular Expression you have designed is working correct, you can use that in Object repository or in descriptive programming.

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What are the metacharacters (special characters ) in regular expressions in QTP?

Below is the list of all meta characters in QTP.


\ -  indicates that the next character would be a special character, a literal or a backreference

^  - Input String should be matched at the beginning.

$  - Input String should be matched at the end.

*  - Matches the preceding character zero or more times. It is same as {0,}.

+  -  Matches the preceding character one or more times.  It is same as {1,}.

?   - Matches the preceding character zero or one time.  It is same as {0,1}

{i} - Matches the previous character exactly i times.

{i,} - Matches the previous character at least i times and at most any time.

{i,j} -Matches the previous character at least i times and at the most j times.

.     -  Matches any single character except "\n".

(pattern) -  Matches pattern and captures the match that can be used in backreferences.
 p|q  -  Matches either p or q. Please note that p and q could be more complex regular expressions

[pqr]  - A character set. Matches any one of the character inside the brackets.

[^pqr]  - A negative character set. Matches any character not inside the brackets.

[p-z]   -  A range of characters. Matches any character in the specified range i.e p,q,r,....x,y,z.

[^p-z]  -  A negative range characters. Matches any character not in the specified range i.e. a,b,c...m,n,o 

\b      -  Matches the boundary of the word

\B      -  Matches middle part of the word.

\d      -  Matches a digit character. same as [0-9].

\D      -  Matches a nondigit character. same as  [^0-9].

\f , \n and \r     -  Matches a form-feed character, newline and carriage character.

\s    - Matches any white space character including space, tab, form-feed. Equivalent to [ \f\n\r\t\v].

\S      - Matches any non-white space character. Equivalent to [^ \f\n\r\t\v].

\t  , \v   - Matches a horizontal and  vertical tab character.

\w      - Matches alpha numeric character including underscore. Equivalent to '[A-Za-z0-9_]'.

\W      - Matches any non - alpha numeric character. Equivalent to '[^A-Za-z0-9_]'.

\number- A reference back to captured matches.

**********************************************************************************

**********************************************************************************

Some examples on regular expressions:
  1. To match the 10 digit mobile number ->  \d{10}
  2. To match email address  -> \w+@\w+\.\w+
You can use regular expression evaluator introduced in QTP 11 to test above regular expressions.

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Wednesday, 20 November 2013

How to use regular expressions in object repository (OR) in QTP?

Object repository stores the test object properties and their values. We can use regular expressions to set the values of the properties of the test object.

When we use the value as a regular expression, single test object in OR can be be used to find the multiple run time objects.

Example -


As shown in above image, we need to click on the button (circled with red) in front of the property value that you want to make as a regular expression. After you click that button, you will get below window

Then we need to enter the regular expression in the edit box and check the regular expression checkbox and click on Ok.

So now the test object will identify all the edit boxes that starts with q followed by any characters.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What is the Difference between local and shared object repository (OR) in QTP?

Object repository is used to store the test object and its properties/values. There are 2 types of Object Repositories.
  1. Local
  2. Shared
Difference between local and shared OR

  1. Local OR is used by only one action in Test While Shared OR can be used by multiple actions and tests
  2. Local OR can be edited without OR manager While shared OR can be edited by using only OR manager
  3. We can not merge 2 local OR but we can merge 2 shared ORs using OR manager
  4. We can not compare 2 local OR but we can compare 2 shared ORs using OR manager
  5. We can associate/disassociate the shared OR to test at run time but Local OR is associated to test at anytime by default.
  6. Extension of the shared OR is .tsr while Local OR is .mtr
  7. When we export the Local OR, shared OR is created.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to use regular expression in descriptive programming in QTP?

As we know that there are 2 ways of descriptive programming.

  1. Static
  2. Dynamic
We can use  regular expression in both the ways as mentioned below. Please note that by default all the property values are considered as regular expressions by QTP.


' Regular Expressions in Static descriptive programming in QTP.

Browser("index:=0").page("title:=Google").Webedit("name:=q").set "sagar salunke"
Browser("creationtime:=0").page("title:=Google").Webbutton("name:=Google.*").Click

Please note that last statement uses regular expression to identify the button whose name starts with Google.
If your property value itself contains the special character then that should be escaped using \ character.

Example - Suppose you want to click on the link "+sagar".
Now this link contains the special character +. To click on this link, we can use below code
Browser("creationtime:=0").page("title:=Google").Link("innertext:=\+sagar").Click


' Regular Expressions in Dynamic descriptive programming in QTP.

Set descriptionObject = Description.Create()
descriptionObject("innertext").value = "+sgaar"
descriptionObject("innertext").RegularExpression = false

'Please note that we can specify whether the value is regular expression or not using RegularExpression property. By default it is true.

Browser("index:=0").page("title:=Google").Link(descriptionObject ).click

This is how we can use Regular Expressions in QTP

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to create the case insensitive regular expressions in QTP?

Many times we need to find the string in given file and we are not worried about the upper case or lower case. In such scenarios we can create case insensitive regular expressions in QTP.

Case Sensitive Search
'**********************************************
'With IgnoreCase = false
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "Tendulkar"

  regExpObject.IgnoreCase = false

  set matches = regExpObject.execute(search_string)

   print matches.count
'**********************************************
'output is 0
'**********************************************

Case Insensitive Search
'**********************************************
'With IgnoreCase = true
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "Tendulkar"

  regExpObject.IgnoreCase = true

  set matches = regExpObject.execute(search_string)

   print matches.count
'**********************************************
'output is 1
'**********************************************


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Explain Global property of the RegExp object in QTP

Global property is used to tell how many matches should be found in the given string.

Examples to understand the global property are given below.

'**********************************************
'With global = false
'When we set the global property to false, we get only first match
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "tendulkar"

  regExpObject.Global = false      

  set matches = regExpObject.execute(search_string)

   print matches.count

'**********************************************
'output is 1
'**********************************************



'**********************************************
'With global = true
'When we set the global property to true, we get all matches
'**********************************************
  Set regExpObject = New RegExp  
  search_string = "Arjun tendulkar is the son of sachin tendulkar"
  regExpObject.Pattern = "tendulkar"

  regExpObject.Global = true

  set matches = regExpObject.execute(search_string)

   print matches.count

'**********************************************
'output is 2
'**********************************************
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Explain RegExp Object in QTP

RegExp is a very important object in QTP that can be used to find the patterns in given string using regular expressions.

This object can be created using below syntax.
 Set regExpObject = New RegExp  

RegExp Object supports below properties.

Global Property     - a pattern should match all occurrences in string or just the first one
IgnoreCase Property - specifies if the search is case-sensitive or not
Pattern Property    - Sequence of literal characters and special characters (Meta Characters like *,?,+,\b,\d,\n etc)

RegExp Object supports below methods.

Test Method     - returns true if the pattern is found in the given string
Execute Method  - returns a Matches collection containing a Match object(having properties firstindex and value) for each match found in string.
Replace Method  - replaces the matched values in the given string by another value


Sample Example on Execute method.

'*******************************************************
 Set regExpObject = New RegExp  
  search_string = "MS dhoni is very lucky cricketer"
  regExpObject.Pattern = "lucky"

  regExpObject.Ignorecase = true
  regExpObject.Global = true
 
 Set matches  = regExpObject.execute(search_string)

 For each match in matches
print  match.firstIndex & " - " & match.value
 Next
'*******************************************************
In above example we are trying to find the pattern "lucky" in the given string "MS dhoni is very lucky cricketer". We are also printing the position where the match is found.

You may also like below topics on regular expressions in QTP.
  1. Regular Expressions in OR in QTP.
  2. Regular Expressions in descriptive programming in QTP.
  3. Regular expression evaluator in QTP.
  4. Meta characters in regular expressions.
  5. Case insensitive regular expressions in QTP.
  6. Regexp object in QTP.
  7. Global Property in Regular Expressions
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Tuesday, 19 November 2013

Applications and Examples of Regular Expressions in QTP

Well - Before I jump to the applications of regular expressions, Let me explain what regular expressions are.

Definition :
A regular expression is a pattern of characters(meta characters and special characters).

General Applications of Regular Expressions :
Where are regular expressions used.
  1. Pattern Matching in Strings
  2. To find the occurrences of one string/pattern in given string.
  3. To replace the patterns with another string in a given text
All programming languages support the use of regular expressions. 

Regular Expressions in QTP :
We can use regular expressions in qtp in many ways as mentioned below.

  1. In QTP, object repository is used to store the object's properties and values. We can use regular expressions to specify the object property value.This helps us using same test object to identify multiple run time objects in the application. 
  2. We can also use regular expressions in descriptive programming. 


QTP examples on Regular Expressions:  
As I said earlier We use regular expressions to check if the given string matches the specified pattern.
For example - Consider a scenario where you have to validate that the given string should be a valid email address.

So list of valid email addresses are - reply2sagar@gmail.com, ayx@jjjj.in etc
Some of the invalid email addresses are - kjkjj@fdff, @dfdf.in etc

With the help of regular expression, you can easily validate the email address.

Syntax of Regular Expression in QTP:
In any QTP program related to regular expression, you will follow below steps.
  1. Create a regular expression object (RegExp)
  2. Define the pattern using RegExp object's pattern property.
  3. Use test method to check whether the given string matches with the pattern specified in step 2.
'Create the regular expression object
Set myRegEx = New RegExp 

'Specify the pattern (Regular Expression)
myRegEx.Pattern = "[a-z0-9]+@[a-z]+\.[a-z]+"

'Specify whether the matching is to be done with case sensitivity on or off.
myRegEx.IgnoreCase = True

'Use Test method to see if the given string is matching with the pattern
isMatched = myRegEx.Test("reply2sagar@gmail.com")

Variable isMatched will be true if the string "reply2sagar@gmail.com" matches with the given pattern 
"[a-z0-9]+@[a-z]+\.[a-z]+"

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.