Micro Focus QTP (UFT) Forums
How to select a particular check box from a list - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to select a particular check box from a list (/Thread-How-to-select-a-particular-check-box-from-a-list)



How to select a particular check box from a list - umer830 - 01-19-2010

Another Problem

I need to select a particular check box as shown in screenshort based on the adajacent document link. Once checkbox selected I can perform a ragen of features available in application,

To identify any of the document link I can use code below and it works
///////////////////////////////////
Code:
If Browser("projectCentre QTP:TEST-AT:").Page("projectCentre QTP:TEST-AT:").Frame("RegRegRegFrame").Exist Then
    set odesc = Description.Create
    odesc("micclass").value = "Link"
    odesc("text").value = Parameter ("Folder_Name" )

MainFolder = odesc("text").value
    set LinkCollection = Browser("projectCentre QTP:TEST-AT:").Page("projectCentre QTP:TEST-AT:").Frame("RegRegRegFrame").ChildObjects(odesc)
    linkcount = LinkCollection.count

    If  linkcount > 0 Then

        For i = 1 to linkcount
            LinkCollection(0).click
            Parameter("Return") = 1
Reporter.ReportEvent micPass, "Floder found and Opened ", MainFolder
        Next
    else
            Parameter("Return") = 0
Reporter.ReportEvent micFail, "Floder not found in the main rigister ", MainFolder
    End If
//////////////////////////////////////

But next I need is once the link is identified say 'DEC 3' I have to slect the adajacent check box which cannot be identified based on webtable row neither it can be recorded as it will differ based on web link you want to select.

Q1:Can you guys suggest a wayout to select a particular checkbox

Q2:You can see the image of my object repository and object spy, The difference I am trying to under stand is in Object spy it shows checkbox as a child of webtable where as in object repository it doesn't. If I can have it as child of webtable in OR I can easily identify target checkbox based on rownumber and some looping code

Waiting for any kind of help


RE: How to select a particular check box from a list - sreekanth chilam - 01-19-2010

Hi Umer,

Follow the below steps.

Step1: Add the required 'WebTable' Object into Obj.Repo

Step2: Retrieve the row count of the webtable.

Step3: Loop thru all the rows & retrieve required cell's data using 'GetCellData' method & Validate the current link text with expected link text.

Step4 : If the required link text is found in 'i'th row, then use 'ChildItem' Method & select the correspoding CheckBox present in the same row & Exit out of the Loop.

Refer the below example code:
Code:
Expected_Link="DEC 3"
rc= Browser("projectCentre QTP:TEST-AT:").Page("projectCentre QTP:TEST-AT:").Frame("RegRegRegFrame").WebTable("...").RowCount
For i=1 to rc
  Table_linkText=Browser("projectCentre QTP:TEST-AT:").Page("projectCentre QTP:TEST-AT:").Frame("RegRegRegFrame").WebTable("...").GetCellData(i,3)
If (Expected_Link=Table_linkText) then
  Browser("projectCentre QTP:TEST-AT:").Page("projectCentre QTP:TEST-AT:").Frame("RegRegRegFrame").WebTable("...").ChildItem(i,1,"WebCheckBox",0).Set "ON"
Exit For
End if
Next



RE: How to select a particular check box from a list - umer830 - 01-21-2010

Thanx sreekanth. It worked Smile


RE: How to select a particular check box from a list - ranjanisudarmani - 10-18-2012

Hi Umer,

Browser("projectCentre QTP:TEST-AT:").Page("projectCentre QTP:TEST-AT:").Frame("RegRegRegFrame").WebTable("...").ChildItem(i,1,"WebCheckBox",0).Set "ON"

The above code is not working for me . i am always facing an error "Object Required"

Thanks
Ranjani.S


RE: How to select a particular check box from a list - agarwl.anurag - 10-18-2012

Hi,

Did u add webtable element in your object repository?


RE: How to select a particular check box from a list - ranjanisudarmani - 10-19-2012

Yes i have added web table in OR. since i am facing the problem


RE: How to select a particular check box from a list - vjjohnson04 - 10-23-2012

I execute the code in this way and get an error

Error Message: Wrong number of arguments or invalid property assignment: 'oPage.WebTable(...).ChildObjects'

Line (93): "oPage.WebTable(Result_Grd).ChildObjects(i,3)(oChkBox).set "ON""

code:
Code:
Set oPage = Browser("micClass:=Browser").Page("micClass:=Page")
Result_Grd = "html id:=ResultGridCtl"

Set oChkBox = Description.Create()
oChkBox("micClass").value = "WebCheckBox"
oPage.WebTable(Result_Grd).highlight
If oPage.WebTable(Result_Grd).Exist Then

For i=3 to 10
        
        oPage.WebTable(Result_Grd).ChildObjects(i,3)(oChkBox).set "ON"

Next
    

End If