Tuesday, January 19, 2010

Deselect all radio buttons

Radio buttons work in groups unlike check-boxes. 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.

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("Internet Explorer").Page("Msn").object.getElementsByTagName("INPUT")

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


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.

1 comment:

QPT said...

You have explained very clearly how to
Deselect all radio buttons.thanks for sharing.
QTPbook

Script no right click

Selection Disable Script