Thursday 20 February 2014

How to find all check boxes on the webpage in QTP?

In web applications, we can find the web checkbox objects in 2 ways.
  1. using QTP childobjects method
  2. using html DOM
using QTP childobjects method

Set oDesc = Description.Create()
oDesc("micclass").Value = "Webcheckbox"

'identify objects inside parent page having micclass as Webcheckbox
set col = ObjParent.childobjects(oDesc)

'print the count of checkboxes on the page.
msgbox col.count


using HTML DOM

set col = Browser("index:=0").page("index:=0").object.getElementsByTagName("input")
msgbox col.length

'Above code will give all objects starting with input tag. You can filter those having type = checkbox using below code.


For i=0 to col.length-1
If  col(i).getAttribute("type")  = "checkbox" Then
cnt = cnt +1
End If
Next


print cnt


'above code print the type attribute value. If it is checkbox , that means given control is web checkbox.

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.