As we know that there are 2 ways of descriptive programming.
' 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.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
- Static
- 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.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs