Editorial / Best Answer
priyankvyas
Regular expression is always used to make our search globalize.
To execute the test in QTP every object is searched in the object repository (OR). In
real time applications some object's properties always keep changing, so at the
time of execution script fails. To overcome it we use "regular expression" for
that particular object's property. For example:
1) Record a test where you are inserting one order and than faxing the same order.
2) The order number that is generated during recording may 21 and "Fax Order window title" is generated and saved into OR as "Fax Order No. 21"
3) Now execute the same test, the script will fail because this time order no is modified as 22 and accordingly "Fax Order window title" is modified as "Fax Order No. 22".
4) This time the object "Fax Order No. 22" is not identified or you can understand object is not matched (find) into OR.
5) To make this search better we modify the text property of object into OR as "Fax Order No.*" this will search all the
occurrences of window that has text as "Fax Order No"
6) We can also write it as "Fax Order No. [0-9]" because fax order no is a numerical value and this will search only numbers after "Fax Order No. "
So this is the purpose of regular expression in QTP.
QTP Regular Expression
Profile Answers by rashidansari1 Questions by rashidansari1
Questions by rashidansari1
Editorial / Best Answer
priyankvyasProfile Answers by priyankvyas Questions by priyankvyas
Regular expression is always used to make our search globalize.
To execute the test in QTP every object is searched in the object repository (OR). In real time applications some object's properties always keep changing, so at the time of execution script fails. To overcome it we use "regular expression" for that particular object's property. For example:
1) Record a test where you are inserting one order and than faxing the same order.
2) The order number that is generated during recording may 21 and "Fax Order window title" is generated and saved into OR as "Fax Order No. 21"
3) Now execute the same test, the script will fail because this time order no is modified as 22 and accordingly "Fax Order window title" is modified as "Fax Order No. 22".
4) This time the object "Fax Order No. 22" is not identified or you can understand object is not matched (find) into OR.
5) To make this search better we modify the text property of object into OR as "Fax Order No.*" this will search all the occurrences of window that has text as "Fax Order No"
6) We can also write it as "Fax Order No. [0-9]" because fax order no is a numerical value and this will search only numbers after "Fax Order No. "
So this is the purpose of regular expression in QTP.
Related Answered Questions
Related Open Questions