How to select a radio button using WebRadioGroup in QTP/UFT

CODE: Browser("title:=Forms : Radio Button - HTML Tutorial").Page("title:=Forms : Radio Button - HTML Tutorial").WebRadioGroup("name:=radio1", "Index:=0").Select "#2"

Hello! I am going to show you how to select a radio button using  the WebRadioGroup object in QTP. There are several ways of selecting a radio button with QTP/UFT. If the WebRadioGroup object is available, this method will be quick and stable. In cases where the WebRadioGrop object is not available, using other methods may be more efficient. I will cover these methods in later posts. The code above can directly be copied and pasted into your QTP/UFT automation tool. Just replace the property's information based on your pages and objects. If you would like a step by step process on how to select a radio button in QTP/UFT, follow the steps below.

1. Go to the website http://www.echoecho.com/htmlforms10.htm

2. Click on the object spy in QTP/UFT and select a radio button on this page. In this example, the radio button can only be spied on when it is selected on the page

3. The title is a unique property for both the Browser and Page. Copy the title property's for both the Browser and the Page, and paste them in your object's description.  The code should look like the example below.

ex. Browser("title:=Forms : Radio Button - HTML Tutorial").Page("title:=Forms : Radio Button - HTML Tutorial")

4. Next, you want to identify the WebRadioGroup Object. The "name" is a unique property for this group so copy and paste the name into your object's description. Also, I like to use the index in object identification, in case the object property name changes. In this case, the index of this object is 1 as you can see in the "selected item index" property. Your code should look like the example below.

ex. Browser("title:=Forms : Radio Button - HTML Tutorial").Page("title:=Forms : Radio Button - HTML Tutorial").WebRadioGroup("name:=radio1", "Index:=1")

5. Lastly, you want to select the radio button by using the "Select" method. You should select the radio button by locating the "value" property for the WebRadioGroup within the object spy. In this scenario, radio button 1 has a value of #0, radio button 2 has a value of #1, and radio button 3 has a value of #2. Your code should look like the example below.

ex. Browser("title:=Forms : Radio Button - HTML Tutorial").Page("title:=Forms : Radio Button - HTML Tutorial").WebRadioGroup("name:=radio1", "Index:=1").Select "#2"

Copy and paste this code into your QTP/UFT automation tool.

In this case, I am selecting the 3rd radio button.

 

There you have it! You have successfully selected a radio button using WebRadioGroup with QTP/UFT. Stay tuned for more awesome tutorials!

 

 

 

 

Pin It on Pinterest

Clef two-factor authentication