Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
WhatsApp to 91-8328152362 for address details of AnyTechLabs
Selenium + Appium 27th February 2019 7.00 AM IST to 8:45 AM IST 45 Days Class Room + Online AnyTechLabs
Selenium + Appium 9th March 2019 9.00 AM IST to 2.00 PM IST 5 WeekEnds Class Room + Online AnyTechLabs

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