Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
New Schedule in MindQ Systems, Madhapur By SUDHAKAR
Course Name Date Time Duration Type Branch
UFT + UFTPro 20th September 2017 7.30 AM - 9.00 AM IST 25Days Classroom + Online Hitech City
Selenium+Appium 4th October 2017 4.30 PM - 6.00 PM IST 40Days 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?
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