Skip to Content
QuickTest Professional (Mercury’s functional and regression test automation tool) uses VBScript as its scripting language.
One cool feature of QuickTest (a.k.a QTP) is the “With” Statement.

With statement allows you to perform a series of statements on a specified object without re-qualifying the name of the object. With statements make your script more concise and easier to read and write or edit by grouping consecutive statements with the same parent hierarchy.

Example:

You can replace this script:
Window(“Flight Reservation”).WinComboBox(“Fly From:”).Select “London”
Window(“Flight Reservation”).WinComboBox(“Fly To:”).Select “Los Angeles”
Window(“Flight Reservation”).WinButton(“FLIGHT”).Click

With the following:
With Window(“Flight Reservation”)
   .WinComboBox(“Fly From:”).Select “London”
   .WinComboBox(“Fly To:”).Select “Los Angeles”
   .WinButton(“FLIGHT”).Click
End With

Happy Coding!
Asaf Saar

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply