Micro Focus QTP (UFT) Forums
Search and click on URL - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Search and click on URL (/Thread-Search-and-click-on-URL)



Search and click on URL - Z_Melb - 10-21-2010

Hi All,

How do I search for a list of products by their ID and make QTP to click on their respective URLs? I can add the products in Datatable and able to search for the given products but I cannot make QTP to click on the changing URLs. Every time a new product is searched, the URL will change.

I have been trying to make this work but going no where.
I would really appreciate anyone's help as I need this for work purpose.

Pls see the attachment.

Thank you
Z
[attachment=525]
[attachment=526]


RE: Search and click on URL - KavitaPriyaCR - 10-21-2010

Hi
You can use DP to get all links in the page and click on 1st link by using the index as 0.
OR
try for last statement as:
Code:
Browser("Officeworks | Officesupplies,").Page("Officeworks | Officesupplies,_2").Link("index:=0").Click
If this didn't work and if the link name begins with "Officeworks", then try with
Code:
Browser("Officeworks | Officesupplies,").Page("Officeworks | Officesupplies,_2").Link("name:=Officeworks.*,index:=0").Click

Please let me know if u get any problem.


RE: Search and click on URL - Z_Melb - 10-21-2010

Hi Kavita,
thank you very much for your reply.
i like to mention here that, i am a new user in QTP. So you might have to be little descriptive please Smile
What is DP that you mentioned?
I tried your 2nd solution, it can search for the list of products from Datatable but does not CLICK on the individual URLs.
The 3rd solution didn't work.
Sad
Z


RE: Search and click on URL - KavitaPriyaCR - 10-21-2010

Sorry, DP >> Descriptive Programming
Add these lines after your second line i.e, after search action
Code:
set Ldesc=Description.create()
Ldesc("micclass").value="Link"
Ldesc("name").value="Officeworks.*"
set objWebLink=Browser("Officeworks | Officesupplies,").Page("Officeworks | Officesupplies,_2").ChildObjects(Ldesc)
If objWebLink.Count>0 Then
' As i am seeing the link with that name is only one on the page, i am using 1st link to click  as:objWebLink(0)
objWebLink(0).Click
End If



RE: Search and click on URL - Z_Melb - 10-22-2010

Hi Kobita,
Thank you for trying to help me. This is how the script look -

Code:
Browser("Officeworks | Office Supplies,").Page("Officeworks | Office Supplies,").Sync
Browser("Officeworks | Office Supplies,").Page("Officeworks | Office Supplies,").WebEdit("query").Set "PPS142380"
Browser("Officeworks | Office Supplies,").Page("Officeworks | Office Supplies,").Image("Search").Click 32,6

set Ldesc=Description.create()
Ldesc("micclass").value="Link"
Ldesc("name").value="Officeworks.*"
set objWebLink=Browser("Officeworks | Officesupplies,").Page("Officeworks | Officesupplies,_2").ChildObjects(Ldesc)
If objWebLink.Count>0 Then
    objWeblink(0).click
    end if
    
Browser("Officeworks | Office Supplies,").Page("Officeworks | Office Supplies,_2").Link("Pack Post Send Envelopes").Click

But, when i run the script i get an error "The "Officeworks | officesupplies," browser object was not found in the object repository. Check the boject repository to confirm that the object exists or to find the correct name for the object."

Do I have to create object repository? I dont have any.

Cheers
Z


RE: Search and click on URL - KavitaPriyaCR - 10-22-2010

Sorry, Please write as:
Code:
set Ldesc=Description.create()
Ldesc("micclass").value="Link"
Ldesc("name").value="Officeworks.*"
set objWebLink=Browser("Title:=Officeworks | Officesupplies,").Page("Title:=Officeworks | Officesupplies,_2").ChildObjects(Ldesc)
If objWebLink.Count>0 Then
objWeblink(0).click
end if

I forgot to mention Title for Browser and Page, pls let me know.


RE: Search and click on URL - Z_Melb - 10-22-2010

Sad No luck, get an error. Pls see the attachment.
Do you have an example that I can use, where you can search for something and able to click on the first result that displays? As you know, there will be a list of things to search, so the first result will always change based on the search.
Thank you for helping me.