QTP/UFT tutorial for beginners: 3 easy ways to Identify and click on a drop down list with checkboxes

Happy Monday! Today we have a fun tutorial which was requested by one of our amazing users! He was having trouble with identifying a web checkbox within a drop down list. I will be showing you how to do just that in 3 simple different ways.

If you click on this button

Automation Practice Page,

it will take you to our automation practice page. At the bottom right of the list, we created a dropdown list with 3 checkboxes.

When starting out, always think of automation in terms of how a manual user would access or click a specific object. In this case, there are two steps we have to go through. 1. Click the dropdown list and 2. Click a specific checkbox.


1. Click on your QTP/UFT object spy tool and click on the dropdown list with the checkboxes. You can see that the list is a web element. Click on the copy to clipboard icon and grab the innertext property and it's value.

Now create the code to access this element. Make sure that the only browser windows you have open are this tutorial, and the automation practice page.

Browser("Index:=1").Page("title:=.*").WebElement("innertext:=Checkboxes in a dropdown - open and select checkboxes").Click

Congrats! We completed step one!

2. Step two is to select a checkbox after the list has expanded. We will select the second checkbox. Repeat the steps from step one to identify the checkbox. In this case, we will use the name property and it's value.


Now run both of these lines of code, and you  will see the automation in action.

Browser("Index:=1").Page("title:=.*").WebElement("innertext:=Checkboxes in a dropdown - open and select checkboxes").Click



You did it! Pretty easy right? But there is more than one way that we can do this. Although we currently have two steps for clicking a checkbox in a dropdown list, you don't necessarily have to click on the dropdown list first. The checkboxes are automatically loaded on the page but are not visible until a user clicks on the dropdown list. QTP/UFT automatically has access to all the objects on the page whether they are visible or not. Let's see how this works.

Uncheck the second checkbox and collapse back the dropdown list. Now instead of using the code above, just use the code below.


You can see that the code ran successfully, but you couldn't visually see if the checkbox was clicked or not. Now open the dropdown list and you will in fact see that although the list was collapsed, QTP/UFT still selected the checkbox.


There are a lot of different ways to identify objects. We want you to know and understand all of them because different methods apply to different applications. The more you know about how QTP/UFT operates, the better you will be as an automation engineer.

The third method to identify this list, is to use the index property. As you can see, the C value is the only value that changes for the name property for each checkbox.




Let's replace the C values 1, 2, and 3 to make the code more dynamic. Delete everything after the letter c, and replace it with .* This tells QTP/UFT to find any object that starts with the name c. Anything that comes after C will not matter to QTP/UFT.


Lastly, now that our name property can dynamically identify any of the checkboxes, we will add an index to differentiate between the 3 checkboxes.

Browser("Index:=1").Page("title:=.*").WebCheckBox("name:=c.*", "Index:=0").Click

Now, just by changing the value of the index from 0, 1, or 2, we can select any of the three checkboxes.

Great! You did it! Now you can easily identify web checkboxes in 3 different ways!! Please post your questions or comments below. We love your feedback so we can grow and better our service for you. We also love helping you so please post your requests!

Pin It on Pinterest

Clef two-factor authentication