Create a class module in testpartner to extend the methods and examples supported by the test object

Source: Internet
Author: User

Testpartner implements VBA (an object-oriented script language) as an automation client, and models the elements of an application under test as objects exposed to VBA. this is the purpose of using tposi objects and the testpartner Type Library. the testpartner Type Library defines the properties, methods, and events available for each tposi object, allowing design time interrogation of these objects, a concept known as early binding.

However, a powerful feature of an automation client such as VBA is the support of late binding. late binding allows an object to be generically typed (as object) at design time, then interrogated at run time for the properties, methods, and events that are not exposed at design time. tposi objects do not inherently support late binding, which does not present an issue for traditional applications where the role of each object is clearly delimited and can be interrogated at design time, but does present an issue in respect to modern object-oriented systems such as ActiveX controls, Java, and. net. in such systems, testpartner's tposi objects have restricted access to application objects at design time. only the properties, methods, and events listed in the testpartner Type Library are available, and without late binding support, much of the functionality in the objects of the application wowould remain closed for interrogation.

In order to support late binding, testpartner offers object extension through the idispatch interface. using the methods of idispatch combined with the object () method from tposi, testpartner has the ability, at run time, to interrogate late bound objects in an application under test.

Tip: To view an object's run-time properties exposed by the object () method, open the Watch window and set a breakpoint in your test script. in debug mode, you can expand the nodes to display the properties.

The following steps provide an example of employing the Internet Explorer Object Model to extend testpartner's standard support. the example makes use of the object () method to generically define the thtmltable object inside the Internet Explorer browser, and interrogates the late bound thtmltable object at run time.

To extend testpartner's object support for base objects-Example:

Start testpartner.

Click File> new. A new asset dialog box appears:

Create a new class module, and click OK. A blank class module appears.

Click Insert> file..., and use the browser that appears to open and insert c: \ Program Files \ micro focus \ testpartner \ samples \ thtmltableex_classmodule.txt.

This file provides a wrapper around the thtmltable object to interface with the Microsoft Internet Explorer HTML object model. notice that the Code contains an object () method in the click () function. it's through the use of the object () method that the code can access the actual object from the Internet Explorer's object model, and make callto the object at run time.

In order to access attributes of the interfaces used in this class module, there must be a reference made to the Microsoft HTML Object Library. Follow Steps 5 and 6 to create this reference.

Click View> Object Browser. The object browser appears.

Right-click anywhere in the Object Browser and choose references from the menu, A references dialog box appears. Scroll down the references list and put a checkmark next to Microsoft HTML Object Library. Click OK.

Close the Object Browser.

Save the class module, naming it thtmltableex, and close the class module.

From the Windows Explorer, double-click the HTML file: C: \ Program Files \ micro focus \ testpartner \ samples \ thtmltableex_demo.htm to open it in an Internet Explorer window. this file contains the HTML table that is interrogated at run time.

Return to testpartner. click File> new. A new asset dialog box appears. Create a new test script, and click OK. The view code window appears with some text. Clear all text.

Click Insert> file ..., and use the browser that appears to open and insert c: \ Program Files \ micro focus \ testpartner \ samples \ thtmltableex_example_script.txt. this file is a test script which attaches to the running HTML table object, retrieves text from cells in the object, and automates objects inside the tables cells.

Save the test script, naming it tableexample, then play it back. Click OK when prompted, and notice that the test script is able to interrogate and manipulate data and control in the HTML table object.

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.