Micro Focus QTP (UFT) Forums
QTP - Code to select a link - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: QTP - Code to select a link (/Thread-QTP-Code-to-select-a-link)



QTP - Code to select a link - Unleash Rajesh - 06-21-2011

Hi...

I want to click on the log-in link which is on the right side of the page with descriptive programming...Please Provide me the code..

I have tried this,..

Code:
Browser("Browser").Page("Page).Link("Login").Click

But it throws an error...Help me to solve this


RE: QTP - Code to select a link - Unleash Rajesh - 06-23-2011

Hi...

I got the answer...Try this

Code:
Dim obj
Set a=Description.Create
a("html tag").value = "A"
a("micclass").value="Link"
a("innerhtml").value="Login"
set obj = Browser("Micclass:=Browser").Page("Micclass:=Page").ChildObjects(a)
x= obj.count
For i=0 to x-1
obj(i).click
Next



Hi..

Got a solution...Try this...

Code:
Dim obj
Set a=Description.Create
a("html tag").value = "A"
a("micclass").value="Link"
a("innerhtml").value="Login"
set obj = Browser("Micclass:=Browser").Page("Micclass:=Page").ChildObjects(a)
x= obj.count
For i=0 to x-1
obj(i).click
Next



RE: QTP - Code to select a link - shivu.hanu - 01-03-2012

BROWSER("TITLE:=FIREST 4 CHARACTER.*").PAGE("TITLE:=FIREST 4 CHARACTER.*").LINK("NAME:=X").CLICK

WHERE X--GO AND SPY AT THE "LOGIN LINK THEN U WILL GET THE NAME OF THE LINK.THEN ENTER THAT NAME IN PLACE OF X


RE: QTP - Code to select a link - prabhukrishna - 01-03-2012

Hi,

Your expectation is to click on a link available in a page that takes you to the next page.

so, the object that you are accessing is link and the method you have to invoke is click

Step1: Set Mandatory properties for browser, page and link if not already set. (ex. for browser set as name, for page set as title and for link set as name)
Step2: Add all the three objects(browser, page and link) to object repository using Add Objects.
Step3: write code to invoke the the application like

"SystemUtil.run "http://www.google.co.in"

Step4: write code to click on the link

Code:
Browser("name:=Google").Page("title:=Google").link("name:=linkname").click
this should work.

Regards,
Prabhu K