Micro Focus QTP (UFT) Forums
Selecting Checkbox one after other - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Selecting Checkbox one after other (/Thread-Selecting-Checkbox-one-after-other)



Selecting Checkbox one after other - rameshrise3 - 08-21-2009

Hi,
I need to check the checkbox based on teh Username, which is teh input value, I pass as a parameter, I need to search the web table 2nd Column & match the Username with the input value and then I have to check teh checkbox.

I have to repeat this for few values,

Please help me in this.


RE: Selecting Checkbox one after other - supputuri - 08-21-2009

HI Rammy,

PFA piece of code and let me know if you need any more info.

Code:
NumRows = Browser("QTP Forums - Search Results").Page("QTP Forums - Search Results").WebTable("Search Results").RowCount
blnCBFlag = False
For LCount =0 to NumRows
    If instr(Browser("QTP Forums - Search Results").Page("QTP Forums - Search Results").WebTable("Search Results").GetCellData(LCount,3),"QTP")>0   Then
        CBNum = Lcount
        blnCBFlag = TRUE
        Exit For
    End If
Next

If blnCBFlag = TRUE Then
    Set oDesc = Description.Create()
    oDesc("micclass").value = "WebCheckBox"
   Set CBCollection = Browser("QTP Forums - Search Results").Page("QTP Forums - Search Results").ChildObjects(oDesc)
    CBCollection(CBNum).set "ON"
End If
Set oDesc = Nothing
Set CBCollection = Nothing



RE: Selecting Checkbox one after other - sreekanth chilam - 08-21-2009

Hi Ramesh,

You can also proceed with the below way too...

Example:
Code:
Expected_User="Donald"
RC=Browser("...").Page("...").WebTable("ActiveUsers").Rowcount
for i=1 to RC
  Current_user=Browser("...").Page("...").WebTable("ActiveUsers").GetCellData(i,2)
     if (Expected_User=Current_user) then
         Set obj=Browser("...").Page("...").WebTable("ActiveUsers").childItem(i,2,"WebCheckBox",0)
         obj.Set "ON"
         Exit For
     End if
Next


You can parameterize user name field(i.e Expected_User=Datatable("UserName",dtGlobalSheet))
and one by one you can select the checkboxes accordingly.


RE: Selecting Checkbox one after other - rameshrise3 - 08-21-2009

Thanks a lot QTPKing & Sreekanth...