Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

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?
image
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  
tblRowCount=oWebTableObject.RowCount  
  
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  
   
Next  
  
End Function  

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

'Calling function  
SelectCheckboxById(aWebTableObject,4,2)  
'4 is the id value, 2 is column id in which id value is available

Result
image


No comments :

Post a Comment