For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
Selenium Framework Development 22nd July 2019 6.30 AM IST to 8:30 AM IST 15 Days WeekDays Online

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Wednesday, March 12, 2014

Select webtable checkbox from dynamically changing table rows

How can you select check box with id “4” in the following web table where the table rows are changing dynamically?
To select checkbox based on id number, we have to follow below steps
Step#1: Identify the row and column numbers of “ID” value in the table using Getcelldata method
Step#2: Based on identified values of step#1, The previous cell of “ID” value is checkbox cell. Apply ChildItem Method to get checkbox object
Step#3: Select checkbox.
Function SelectCheckboxById(oWebTableObject,IdNo,ColumnId)  
'Diclare Variables  
Dim tblRowCount, tblRowIndex, tblCellId  
Dim tblWebCheckBox  
'Get the Row Count of the Webtable  
For tblRowIndex = 1 to tblRowCount  
 'Get cell data of each row  
 tblCellId = oWebTableObject.GetCellData(tblRowIndex,ColumnId)  
 'Compare cell data of each row with the input Id number  
 If tblCellId = IdNo  Then  
  ' Get Checkbox object from the identified column  
  Set tblWebCheckBox = oWebTableObject.ChildItem(tblRowIndex,ColumnId-1, "WebCheckBox",0)  
  ' Set Checkbox on  
  tblWebCheckBox.set "ON"  
  Exit Function  
 End If  
End Function  

'Store WebTable Object in to a variable
Set aWebTableObject=Browser("Browser").Page("Page").WebTable("Catalog")  

'Calling function  
'4 is the id value, 2 is column id in which id value is available


No comments :

Post a Comment