How do you select the first link in a WebTable?

804 views
Skip to first unread message

Lee

unread,
Jun 24, 2007, 11:49:18 PM6/24/07
to QTP - Mercury Quick Test Professional - Automated Software Testing
Hi,

I am relatively new to QTP and I am still getting used to it.

One question that I have is about selecting a link in a WebTable. Each
time I come to the page in question, the WebTable contains a different
named link at the top of the table (due to the search criteria used).
However, I want to be able to record a QTP script that enables it to
select this first link every time regardless of wheather the name of
the link changes.

Does anyone know how QTP can do this?

I would appreciate any assistance.

Regards,
Lee

Dmitry Motevich

unread,
Jun 25, 2007, 6:38:07 AM6/25/07
to Mercu...@googlegroups.com
You have to use DP (Descriptive programming) to process your first link.
 
See an example on how to precess every links on google search results page.
These links are defferent on every page, so i hope this is your case:
Dmitry Motevich,
I'm looking for online/remote job - $0.01/hour
No joking!

Shirish K

unread,
Jun 25, 2007, 6:42:21 AM6/25/07
to Mercu...@googlegroups.com
Try This
 
Set WebEditObj = Browser("XXX").Page("YYY").WebTable( "WebTableName").ChildItem(RwID, ColID, "Link", 0)
WebEditObj.Click

-Shirish

On 6/25/07, Lee <lee...@macquarie.com> wrote:

Shirish K

unread,
Jun 25, 2007, 6:44:47 AM6/25/07
to Mercu...@googlegroups.com
This will required the Webtable and its rowid and columnId which has the generated new link to perform click operation on this.

 
On 6/25/07, Shirish K <shiri...@gmail.com> wrote:
Try This
 
Set WebLinkObj = Browser("XXX").Page("YYY").WebTable( "WebTableName").ChildItem(RwID, ColID, "Link", 0)
WebLinkObj .Click

Lee

unread,
Jun 25, 2007, 10:17:45 PM6/25/07
to QTP - Mercury Quick Test Professional - Automated Software Testing
Hi Shirish,

Thanks for this code.

However, when I run my script in this format (I have added in all the
variables), I get the following Run error:

"Object required: 'WebEditObj'"

Do you know how I could fix this?

Regards,
Lee

On Jun 25, 8:42 pm, "Shirish K" <shirish1...@gmail.com> wrote:
> Try This
>
> *Set WebEditObj =


> Browser("XXX").Page("YYY").WebTable("WebTableName").ChildItem(RwID,
> ColID, "Link", 0)

> WebEditObj.Click*
>
> -Shirish


> On 6/25/07, Lee <lee....@macquarie.com> wrote:
>
>
>
>
>
> > Hi,
>
> > I am relatively new to QTP and I am still getting used to it.
>
> > One question that I have is about selecting a link in a WebTable. Each
> > time I come to the page in question, the WebTable contains a different
> > named link at the top of the table (due to the search criteria used).
> > However, I want to be able to record a QTP script that enables it to
> > select this first link every time regardless of wheather the name of
> > the link changes.
>
> > Does anyone know how QTP can do this?
>
> > I would appreciate any assistance.
>
> > Regards,

> > Lee- Hide quoted text -
>
> - Show quoted text -

Shirish K

unread,
Jun 26, 2007, 8:33:25 AM6/26/07
to Mercu...@googlegroups.com
Actually it should not "WebEditObj" replace it with "WebLinkObj" as per my first mail following is my comments.
 
'Following line of code sets the Object as LinkObject which you want to click
Set WebLinkObj = Browser("XXX").Page("YYY").WebTable("WebTableName").ChildItem(RwID, ColID, "Link", 0)
'Here the Click operation performed on that link
 WebLinkObj.Click
 
Make sure you give same name for the Object and in click operation.
Also make sure the Class of the Link in you application is "Link" or "Weblink" and modify the child item class
 
Let me know if u need more help on this.
 
If same issue then paste your code here to look at that.
 
-Shirish
 

Lee

unread,
Jun 26, 2007, 8:00:56 PM6/26/07
to QTP - Mercury Quick Test Professional - Automated Software Testing
Hi Shirish,

Thanks for the information.

However, I now get the following Run error:

"Object required: 'WebLinkObj'"

Following is the code that I used:

Set WebLinkObj = Browser("XXX").Page("YYY").WebTable("Account
name").ChildItem(1, 1, "Link", 0)
WebLinkObj.Click

Question - You talk about giving a name for the Object. Is this done
in the above code? If not, what else would I have to do?

Regards,
Lee


On Jun 26, 10:33 pm, "Shirish K" <shirish1...@gmail.com> wrote:
> Actually it should not "*WebEditObj*" replace it with "*WebLinkObj*" as per


> my first mail following is my comments.
>
> 'Following line of code sets the Object as LinkObject which you want to
> click

> *Set WebLinkObj


> = Browser("XXX").Page("YYY").WebTable("WebTableName").ChildItem(RwID, ColID,

> "Link", 0)*


> 'Here the Click operation performed on that link

> * WebLinkObj.Click*


>
> Make sure you give same name for the Object and in click operation.
> Also make sure the Class of the Link in you application is "Link" or
> "Weblink" and modify the child item class
>
> Let me know if u need more help on this.
>
> If same issue then paste your code here to look at that.
>
> -Shirish
>

> > > - Show quoted text -- Hide quoted text -

Shirish K

unread,
Jun 28, 2007, 8:03:00 AM6/28/07
to Mercu...@googlegroups.com
Hi Lee,
 
Please spy on the table which you added in this code. e.g. "Account Name" and make sure the same table name is unique in spy window. If there are many with same name then only use that table which has some rows and cols. Also make sure the same table with browser and page is added in your Object Repository.
 
To add exact table in Object Repository Click on the first link which is inside the same table and add table just above the link. i.e. parent table of the link. Then try same code. Code is fine this error might be bcoz u dont have same object in OR.
 
Also one more thing add the table with properties like Name, html tag and index but the index should be for the same name tables other wise set to 0.
 
This will identify that webtable uniquely and no bother in case the index of the table on current page chages in future.
 
Also everytime if browser and page changes its name like XXX_1, XXX_2 then you need to add regular exp for the same so that code will not be dependent on the this above changes.
 
Try this and let me know if it still not worked.
 
-Shirish

 
Reply all
Reply to author
Forward
0 new messages