Micro Focus QTP (UFT) Forums
NEED help with scripting. Web table, Click 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: NEED help with scripting. Web table, Click Link (/Thread-NEED-help-with-scripting-Web-table-Click-Link)



NEED help with scripting. Web table, Click Link - Clymo - 06-08-2012

Could you help me with the following issue, please.

I have à dynamic web table that contains web elements and à link. What i would like to do is check if the data in the globalsheet matches à row in the web table and if so then click on the link. The table looks like the exemple below.

In the Globalsheet I have the Product, Price and OrderDate.
So if the Prodt ZJK with Price 15 and Orderdate 1-6-2012 than click on the OrderNr. The name of the webtable is OrderNrs and the ZKL 15, 1-6-2012 are all web elements

OrderNr Product Price OrderDate ReceivedDateStatus
15 Bonus 1532 7-6-2012 Open
6 ZKL 15 1-6-2012 5-6-2012 Closed
575 Top 111 9-6-2012 Open




RE: NEED help with scripting. Web table, Click Link - sreekanth chilam - 06-08-2012

Hi,

Instead of pasting the code, I suggest you to try this on your own and resolve yourself :-)

Make sure Webtable has unique description and QTP identifíes it properly.

Follow the below process:
Retrieve the data from datatable columns i.e. Product, Price & Orderdate...Say these are Expected Product, ExpectedPrice, ExpectedOrderDate.
Find out RowCount of Webtable.
Use a For loop for looping through the Webtable.
Get the cell values from the column 1,2,3(i.e. Product,Price & OrderDate) for each row and validate them with above expected values
Use a simple "If then" statement so that If current row's cell values are matched with above expected values then use "ChildItem" method to click the correspoding link in that row.
Use exit for to exit the For Loop.




RE: NEED help with scripting. Web table, Click Link - Clymo - 06-08-2012

I tryed it and i cann't Fix it.
Could you give me some example's , please


RE: NEED help with scripting. Web table, Click Link - Clymo - 06-08-2012

It is not that simple Sad


RE: NEED help with scripting. Web table, Click Link - sreekanth chilam - 06-08-2012

Code:
ExpectedProduct=Datatable("Product",dtLocalSheet)ExpectedPrice=Datatable("Price",dtLocalSheet)
ExpectedOrderDate=Datatable("Ord_date",dtLocalSheet)

RC=Browser(...).Page(..).WebTable(..).RowCount
For i=1 to RC
   Actual_Product=Browser(...).Page(..).WebTable(..).GetCellData(i,2)
   Actual_Price=Browser(...).Page(..).WebTable(..).GetCellData(i,3)
   Actual_OrdDate=Browser(...).Page(..).WebTable(..).GetCellData(i,4)
    If (ExpectedProduct=Actual_Product And ....... And ...... ) Then
           Browser(...).Page(..).WebTable(..).ChildItem(i,1,"Link",0).Click
           Exit for
   End if
Next

Now its your turn to implement accordingly buddy Smile