Micro Focus QTP (UFT) Forums
Dynamic link and Regular expression - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Dynamic link and Regular expression (/Thread-Dynamic-link-and-Regular-expression)



Dynamic link and Regular expression - sudhirzpatil - 12-27-2010

Hi All,

In recent Interview I have asked one Question on how to click a link.
The scenario is as below.

On the First page, we have text box.
We have to enter the required text in the Text box, click on Submit button.
On Next page dynamic link generated based on entered text in previous page.

For example

If we enter Shashi Kiran, the link displayed on the next page is
UFC 125:Shashi Kiran's video Interview.

If we enter only Kaitrina,the link name displaced is
UFC 125:Katrina Kai's video Interview.

Here 'UFC 125:' and 'video Interview' remain's constant.

Also the displayed link position on the next page is not constant.It displayed alphabetaly in desc order.

How we handle this situation ?


RE: Dynamic link and Regular expression - Saket - 12-28-2010

it's not required that you should use regualar expression.
you can use descriptive programming for this by forming the links innertext/innerhtml with the input text you entered in the last page.



RE: Dynamic link and Regular expression - sudhirzpatil - 12-28-2010

Hi Saket,
thnks for your valuable reply.
I am not able to validate below script, as it is generic and not related to any particular application.
But still want to conform if below script/approach is correct or wrong.

To enter value in text box

Code:
Browser("name:=orkut - login").Page("name:=orkut - login").WebEdit("text:=Video to search").Set "Kaitrina Kaif"

To get entred text in a variable.

Code:
a= Browser("name:=orkut - login").Page("name:=orkut - login").WebEdit("text:=Video to search").Getroproperty("text")
To click on Submit button

Code:
Browser("name:=orkut - login").Page("name:=orkut - login").Webbutton("value:=Submit")
To click the rquired link.

Quote:
Code:
Browser("name:=orkut - login").Page("name:=orkut - login").Weblink("html tag:=A","inner html:=UFC 125:Katrina Kai's video Interview").click

Please let me know, if i am correct up to this.
Now the problem here is, I want to make above script run for any Text entered in first page.

In the innerhtml Instead of 'Katrina Kai's', I want to pass the variable value I captured during runtime in

Code:
a= Browser("name:=orkut - login").Page("name:=orkut - login").WebEdit("text:=Video to search").Getroproperty("text")

Please correct me if my approach is correct.


RE: Dynamic link and Regular expression - Saket - 12-28-2010

Yes, you in right direction
take a variable and store your input string into it, and use it for the link

e.g
Code:
strInput = "Kaitrina Kaif"
Browser("name:=orkut - login").Page("name:=orkut - login").WebEdit("text:=Video to search").Set strInput
'... rest of the statements to submit
Browser("name:=orkut - login").Page("name:=orkut - login").Weblink("html tag:=A","inner html:=UFC 125:" & strInput & "'s video Interview").click






RE: Dynamic link and Regular expression - sudhirzpatil - 12-28-2010

Thank you very much Saket Smile


RE: Dynamic link and Regular expression - indirani - 03-03-2011

Its very useful. Thank you....but my application Silverlight 4.0. can u give dynamic link validation for supporting silverlight 4.0 application