Monday, February 7, 2011

How to click on dupllicate links?

How to click on duplicate links in a WebTable?

In the below table all the links are having the same names and destinations. So when you read these links to object repository, it will add using index which will not work if any more links are added in the table.

In this cases We have to click on the links based on other cell values. In the below table the Id is unique. So we can write a script to identify the Id value row and click on the select link in the same row.
                                                                                  
IdOpenedClosedNamePartyTypeAmountStatus
Select 13306/17/2009 16:57wAdvertiserCredit123.0000Pending
Select 13206/08/2009 13:0506/08/2009 13:06abcHostPayable2850.0000Complete
Select 13106/05/2009 18:31abcContent ProviderPayable123.0000Pending
Select 13006/05/2009 18:29abcContent ProviderPayable101.0000Pending
Select 12906/05/2009 18:25abcContent ProviderPayable76767.0000Pending
Select 12806/05/2009 18:21abcContent ProviderPayable123.0000Pending
Select 12706/05/2009 18:02abcContent ProviderDebit444.0000Pending
Select 12606/05/2009 17:57defContent ProviderDebit111.0000Pending
Select 12506/04/2009 16:52defContent ProviderPayable111.0000Pending
Select 12406/04/2009 15:4906/04/2009 15:53defAdvertiserReceivable165.0000Complete
Select 12306/04/2009 14:57defAdvertiserDebit100.0000Pending
Select 12206/04/2009 13:4606/04/2009 13:48FghiHostDebit150.0000Complete
Select 12106/04/2009 13:4506/04/2009 13:49FghiHostReceivable150.0000Complete
Select 12006/04/2009 13:3806/04/2009 13:49IncAdvertiserDebit250.0000Complete
Select 11906/04/2009 13:3706/04/2009 13:49FacekHostCredit1500.0000Cancelled
         
2345...>>
Download the Sample WebTable from Here
This Function will click on the select link based on id Provided.
'************************************************************
Function ClickSelectLinkbyId(oTableObject,Id)
rc=oTableObject.RowCount
For r=1 to rc
If cstr(id)=trim(oTableObject.GetCellData(r,2)) then
CellRow=r
Exit For
End if
Next
Set lnkObj=oTableObject.ChildItem(CellRow,1,"Link",0)
lnkObj.click
End Function
'************************************************************
RegisterUserFunc "WebTable","ClickSelectLinkbyId","ClickSelectLinkbyId"
Browser("Browser").Page("Page").WebTable("Id").ClickSelectLinkbyId(132)
UnregisterUserFunc "WebTable","ClickSelectLinkbyId"

No comments:

Post a Comment