Micro Focus QTP (UFT) Forums
Syntax with descriptive programming - 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: Syntax with descriptive programming (/Thread-Syntax-with-descriptive-programming)



Syntax with descriptive programming - martinshort - 05-14-2013

Hi

Anyone able to offer some helpful advice as to why this object can't be found?

I need to be able to programmatically change the index, so it's quite important to be able to do something like this.

Thanks
Martin

Code:
Dim o
Set o = Browser("Browser").Page("Martin Short CanopiusORSA").Frame("Frame").Link("class:=link","text:=Lloyds Submission","color:=#5e1826","index:=5")
o.Click



RE: Syntax with descriptive programming - basanth27 - 05-15-2013

How about check for the childobjects which are link and then find the link with the text=Lloyds Submission and find the index and supply it dynamically to create the object? or if you could find the childobject link which you intend simply click on it.


RE: Syntax with descriptive programming - vinod123 - 05-15-2013

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("innertext:=Lloyds Submission")
instead of changing the index use innetext property of the link


RE: Syntax with descriptive programming - martinshort - 05-15-2013

Hi

Thanks for the reply.

As I understand it, both forms are acceptable. In fact I started off with your version. It's actually the index value that is the critical bit. I need more than one parameter, so tried

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("innertext:=Lloyds Submission", "index:=2)

The aim is to parameterise the index id so that I can loop through the table and click all of the cells in a controlled manner. Each time I try, I can't get UFT to recognise the hyperlink object.

Thanks

Sorry Basanth, I responded to Vinod's reply and then realised that you had also responded.

I think your suggestion sounds good except that I don't know how to loop through the child objects. I tried experimenting with a FOR EACH LOOP, but UFT complained about my syntax.

If you could help here, I would be very grateful!

Martin


RE: Syntax with descriptive programming - vinod123 - 05-15-2013

For Each element In group
[statements]
[Exit For]
[statements]
Next [element]


RE: Syntax with descriptive programming - martinshort - 05-15-2013

Hi Vinod

So what should I use for "element" and what should I use for "group"?Once I know that, I think I can do this.

Cheers.


RE: Syntax with descriptive programming - vinod123 - 05-15-2013

Code:
dim names(2)

names(0)="happy"
names(1)="Sumit"
names(2)="Love"
For Each x in names
document.write(x & "
")
Next



RE: Syntax with descriptive programming - martinshort - 05-15-2013

Hi Vinod

You've given me a general FOR EACH LOOP which is standard for any version of VB/VBS. I don't see how to apply this to my QTP problem.

Code:
Link("innertext:=Lloyds Submission", "index:=myInteger)
doesn't work, Basanth has suggested I loop through child objects where the type is "LINK" and I'm no closer to working out how to do this.

Thanks
Martin


RE: Syntax with descriptive programming - Ankesh - 05-15-2013

@martinshort

Try the below code. You will have to create a description object for link type. And inside the loop u will have to change the index property.

Code:
'Set parent object till the frame
Set oParent=Browser("Browser").Page("Martin Short CanopiusORSA").Frame("Frame")

'Create a description for link
Set objLinkDescription=Description.Create
objLinkDescription("micClass").value="Link"
objLinkDescription("name").value="Lloyds Submission"

'Get the total count
intCount=objLinkDescription.Count

'Run a loop from index 0 till the count
For intIndex=0 to intCount
    'assign index value at run time in loop
    objLinkDescription("index").value=intIndex
    'click on the link
    oParent.Link(objLinkDescription).Click
    msgbox "Click successful"
Next

'Release the object
Set objLinkDescription=Nothing

Let me know if you need more help.

Regards,
Ankesh


RE: Syntax with descriptive programming - martinshort - 05-15-2013

Hi Ankesh

Really helpful. It took some fiddling to get it to recognise the number of rows. Your version kept telling me that there were only two items, but I got there in the end by identifying the table object and used the rowcount property on it.

Much appreciated.
Martin