Micro Focus QTP (UFT) Forums

Full Version: Dynamic link and Regular expression
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
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.
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.
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



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