Qtp User-Defined Function Learning Experience

Source: Internet
Author: User
1. You can use function definition generator to conveniently customize a user-defined function)
2. Built-in function has a higher priority than user-defined function. Therefore, if the same name exists, qtp will first call the built-in Function
3. You can use registeruserfunc to register a custom function as a method for a specific object, or even overwrite the method of the original object ). Unregisteruserfunc
Registration Method: registeruserfunc toclass, methodname, functionname, true
Anti-registration method: unregisteruserfunc toclass, methodname
4. The function defined in the action and the registered method can only be used in the current action. If it is required for global use, it is defined in the function library.
5. If the method is registered in the action and called by other actions, this method definition is also applicable to calling action (calling action ). However, if the function is defined in the called action, the calling action fails because the function definition cannot be found. In this case, you need to define the function in the function library.
6. qtp clears all method register before the test is executed.
7. By default, the running result of user-defined function will not appear in the test result. You can use reporter. reportevent to add logs.
8. qtp loads the associated function library when you open test. Therefore, if another user or you modify the corresponding function library using another Editor, it takes effect only after qtp re-opens the test.
9. The order in which qtp searches for a function is to first test the function library. In addition, when a function with the same name exists in multiple function libraries, the last function is used.
10. Two different functions are registered for the same method. The subsequent method registration will overwrite the previous one. When unregisteruserfunc is used for anti-registration, the method is returned to the original state, instead of returning to the previous registration.
11. After executefile is used in an action, this function can only be used in the current action.
12. For external resources stored in QC, such as function library, a local copy is created when qtp is enabled. Therefore, if another user modifies external resources on QC, Or you use another editor to modify the resource, the modification takes effect only when qtp re-opens the test. However, this problem does not exist for external resources stored locally.
13. After the default function library list is set in test settings, these libraries are integrated into the newly created test when the test is created. Subsequent modifications to the default function library list will not affect the existing test.

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.