WORKING WITH QTP

TestEveryThinG

Posts Tagged ‘WebTable’

Select the row in WEBTABLE/WEBGRID using QTP/DOM

Posted by rajivkumarnandvani on July 23, 2011

Hi All,

I found that most of time while working with WEBTABLE we need to the select the row based on some criteria by clicking checkbox or radiobutton.For that first we have to find the row which we have to select based on value of that row like text/link inside the row.
Here I am giving an example how to select a row in Webtable by finding the text. Logic I am using here is first i will find the row number from webtable where my searching text is present using GetRowWithCellText method then I will provide the column name/index of webtable where checkbox is present.


In below mentioned example I will select the row where Confirmation Number is “15204
Let’s see

Select Date ConfirmationNumber User Name Organization Name
17-SEP-2008
13761
 SMITH’S LP SUPPLY CO.
24-OCT-2008
13808
 Micro Motion test1
30-OCT-2008
13874
 EMERSON PROCESS MANAGEMENT ASIA PACIFIC PTE LTD
13-JUN-2009
15058
 Spartan Controls Ltd.
08-AUG-2009
15204
 Emerson Process Management

 Click here to get full details…

http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-141998662587146404
http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-141998664278824982
http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-141998667291069023

Advertisements

Posted in QTP, WEB | Tagged: , , | 8 Comments »

Performance increase in table lookup functions QTP

Posted by rajivkumarnandvani on May 3, 2009

Using object properties instead of QTP standard functions will improve the performance of QTP tests significantly. In our case, we often want to lookup the location of a certain value in a WebTable. QTP provides several functions to read out data from a table, but is slow when used iterating the table (like two for loops, one iterating the rows, the embedded second one iterating the columns per row).

Example of a conservative way to do this:

Public Function LocateTextInTable(byRef tbl, textToFind, byRef row, byRef col)

For row = 1 to tbl.RowCount
For col = 1 to tbl.ColCount
If tbl.GetCellData(row, col) = textToFind then
LocateTextInTable = True
Exit function
End if
Next
Next

row = -1 : col = -1
LocateTextInTable = False
End Function

The crux is this: .GetCellData is not a very fast method and with a table, consisting of 30 rows and 10 columns, this method is iterated up to 300 times in the most worse case scenario (= text not found).

A faster way to retrieve the data is through the Document Object Model (DOM). This allows you to use the more native properties of an object with the sacrifice of some ease of use.

A table consists of row elements and each row element contains one or more cells. We can iterate them just the same way as we did with the function above:

Public Function LocateTextInTableDOM(byRef tbl, textToFind, byRef row, byRef col)

Dim objRow, objCell

row = 1 : col = 1

For each objRow in tbl.object.Rows
For each objCol in objRow.Cells
If objCol.Value = textToFind then
LocateTextInTableDOM = True
Exit function
End if
col = col + 1
Next
row = row + 1
Next

row = -1 : col = -1
LocateTextInTableDOM = False
End Function

Posted in Miscellaneous, QTP | Tagged: , , , | 3 Comments »

 
%d bloggers like this: