Descriptive Programming Sample Codes

In this blog post, we will see some useful Descriptive Programming Sample Codes which helps you to achieve some basic operations. Below code retrieves number of web buttons in QAInsights window:

Set Desc = Description.Create()
Desc("micclass").Value = "WebButton"
Set Buttons = Browser("QAInsights").Page("QAInsights").ChildObjects(Desc)
MsgBox "Number of Buttons: " & Buttons.Count

Below code retrieves number of text boxes in QAInsights window:

Set Desc = Description.Create()
Desc("micclass").Value = "WinEdit"
Set Edits = Browser("QAInsights").Page("QAInsights").ChildObjects(Desc)
MsgBox "Number of TextBoxes: " & Edits.Count

Below code retrieves number of images present in Mercury Web Tours application:

Set Desc = Description.Create()
Desc("micclass").Value = "Image"
Set Imgs = Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").ChildObjects(Desc)
MsgBox "Number of Images: " & Imgs.Count

Below code retrieves number of web list boxes and selects first item:

Set Desc = Description.Create()
Desc("micclass").Value = "WebList"
Set WebListsCount = Browser("title:=Find a Flight: Mercury Tours:").Page("title:=Find a Flight: Mercury Tours:").
ChildObjects(Desc)
MsgBox "Number of WebLists: " & WebListsCount.Count
'Selects first item in all the list boxes
For i = 0 To WebListsCount.Count -1
    Msgbox WebListsCount(i).GetItem(1)
    WebListsCount(i).Select(1)
Next

Below code retrieves all the items in the web list box and displays it in a message box.

cnt=Browser("title:=Find a Flight: Mercury Tours:").Page("title:=Find a Flight: Mercury Tours:").WebList("name:=fromPort").
GetROProperty("Items Count")
For i = 1 to cnt - 1
    MsgBox Browser("title:=Find a Flight: Mercury Tours:").Page("title:=Find a Flight: Mercury Tours:").WebList("name:=
fromPort").GetItem (i)
 Next

Thanks for visiting QAInsights! Check out our new portal Testifications.com to get updates on Software Testing related certifications. We’re always posting interesting articles on QAInsights. I request you to subscribe so you don’t miss out anything. Searching for QA Jobs Openings, check it at www.QAJobOpenings.com

Want to start a blog like this, please visit SpidyDomain to buy cheap web hosting and register domain.

Subscribe to our QAInsights YouTube Channel | Subscribe our free weekly newsletter

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Learn Kubernetes and Get Certified in CKAD.SHOW ME HOW
+ +
Share via
Copy link