http://quicktesthp.blogspot.com

QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP
expert.qtp@gmail.com

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Thursday, October 22, 2009

QTP Tip: Deselect all radio buttons

Yesterday I got an email from one of my esteemed readers who asked "Is there any way to deselect all radio buttons using HP QTP?" I thought why one would do that but since it has been asked, it has to be answered.

Before answering the above question let me explain that, radio buttons work in groups unlike checkboxes. It means, in a group only a single radio button can be selected. Afterwards, its not possible to deselect all radio buttons in that group. Even manually it can not be done.

Inititally the task seems impossible but its not :)

It is definitely possible to deselect all radio buttons using QTP but it can only be achieved with the help of Document Object Model or DOM.

The QTP Script for the same goes here:

Set Obj = Browser("Google").Page("Google").object.getElementsByTagName("INPUT")

For each RadioBtn in Obj
If lcase(RadioBtn.type) = "radio" Then RadioBtn.checked = False
Next

To know more about the Document Object Model in QTP, see here : http://msdn.microsoft.com/en-us/library/ms533043(VS.85).aspx

Also read about the Object property in WebRadioGroup Object in QTP help for more information.

Note:

Document Object model is supported by Internet Explorer browser only & not for Firefox as the underlying COM technology is not supported by Firefox. Hence, for Firefox browser, QTP will not be able to access the radio buttons using Document Object Model.

Also working with Document Object Model inside HP Quicktest Professional is faster in terms of performance as no object identification is involved.

No comments:

 
Copyright © 2009 ExpertQTP