Three ways to Uft scripts to call external VBS functions

Source: Internet
Author: User

The first method: Executefile, using this function to dynamically load the external VBS, so that the test script can call the VBS file of all functions, the call statement is written below, the order cannot be reversed, otherwise it will be an error. This method is suitable for any version of QTP, but there is a drawback that code debugging can not be traced to the function of the external VBS, it is somewhat inconvenient.

Executefile File

File String the absolute or relative path of the file to execute.

Example:

Executefile "C:\out.vbs"

Outputmsg

-----------Out.vbs-----------

Sub outputmsg MsgBox "Hello world!" End Sub

The second method: Loadfunctionlibrary, which is the new function of QTP11, functions with Executefile, also can introduce external files, its advantage is to support code tracking debugging. Similarly, the call statement is written below, the order cannot be reversed, otherwise it will be an error.

loadfunctionlibrary (Path)

File String the absolute or relative path of the file to execute.

Path String the path (or paths) of the function library to load. You can specify one or more absolute the file system paths, relative paths, or quality Center paths for both Tests and Compone Nts. If you specify multiple paths, separate them using a comma delimiter.

Example:

Loadfunctionlibrary "C:\out.vbs"

Outputmsg

-----------Out.vbs-----------

Sub outputmsg MsgBox "Hello world!" End Sub

The third method: resources, add the VBS file to QTP's resources and support code trace debugging.

File-settings-resources, click on the + number to select the file to add, click Apply, or in the left Resources sidebar, right-click "Associated Function Libraries", and then click "Associated Function Library, select the file you want to join.

Three ways to Uft scripts to call external VBS functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.