QTP10.com is a new and completely free website that offers help in all the versions of HP QTP (including latest version 10). More importantly, it offers free code for users of HP QuickTest Professioal. This site helps you in learning the basics of QTP and descriptive/advanced programming in (QTP) on various environments like - .Net, Infragistics, Web, Windows, etc.

Note -
This blog is NOT affiliated with HP / Hewlett-Packard in any way. The data/questions come from various sources and we have our own testing questions. I am just another Software Tester like you.

Count the number of check boxes available in the webpage by QTP – Childobjects method

Share This Post -

Sponsored Links:

Working with Child Objects – Part 1 - Description Programming, Count ChildObjects, Enumerating ChildObjects

In this post we will discuss:

  • Count the number of check boxes available in the webpage
  • Check All Checkboxes in the webpage

You can copy and pate the below code in QTP and run the script.

'  - - - - - - - - - -  Count & check the number of check boxes available in the webpage '  - - - - - - - - - - 

SystemUtil.Run "iexplore.exe", “http://www.onestopsoftwaretesting.com/qtptest.html”

'Create a Description object
Set dpAllChk = Description.Create

'Define the class of the above created Description object
dpAllChk("micclass").value = "WebCheckBox"

'Getting all the textboxes
Set Allchk = Browser("Browser").Page("Page").childobjects(dpAllChk)

Allchk(0).set "ON"

'count all the textboxes
chkcount = Allchk.Count

msgbox chkcount &  " check boxes are available in the webpage"

'Check all textboxes in the webpage
icounter = Allchk.Count -1
For i = 0 to icounter
Set otext = Allchk.item(i)
‘item property - Exposes a specified item from a collection.
otext.set "ON"

Next

'  - - - - - - - - - - - - - - - - End  - - - - - - - - - - - - - - - -