Define object mandatory mapping encapsulation class (2)

Source: http://blog.csdn.net/zzxxbb112

In the content of the last lecture , we have briefly introduced some basic knowledge of object mapping, but the object mapping provided by qtp itself actually has the problem of transplantation. For example, this object will become invalid when we port the script to another machine. Because the object mapping follows the configuration, and the configuration does not follow the script. It's worth thinking about how to bind these configurations together to the script.

 

In response to the above problems, I provide you two solutions here:

Solution 1: Use the configuration everywhere solution (Generate Script method)

Advantages: convenient and fast, just export the script

Disadvantage: Only object mapping with QTP standard can be applied

Steps: Open Tools --> Object Identification and click after the user-defined mapping is complete

It is recommended to save it to the configuration folder of the main script folder. The file is a vbs file. It is best to add it to the environment pre-configured file to run it.

In this way, when replacing the machine, you only need to execute this file on other machines.

 

Option 2: Change the key value under the ClassMap key of the registry (refer to the Advanced Chapter of QuickTest Unplugged)

Advantages: Can be used for QTP non-standard mapping methods, such as .Net object mapping

Disadvantage: Requires familiarity with registry operation scripts

Steps: Go to HKCU --> Software --> Mercury Interactive --> QuickTest Professional --> MicTest --> Packages

You can see that this figure shows the package files of all installed plugins for QTP. We can expand StdPackage into ClassMap

As shown in the figure, we can see that there are many classes and objects under ClassMap

Pay attention to the right, is there a TXEdit that is very familiar, yes, it is the object we used QTP for mapping before

When using QTP's User-defined function under Object Identification for mapping, the registry will automatically generate such a line of key values

Then this means that we can actually add custom objects directly by modifying the registry.

Here I suggest that you can directly use the RegWrite method of the Wsh object to encapsulate it into a vbs script for mapping.

 

.Net object not recognized? Add directly to the registry to map custom objects

I won't explain this picture, you will understand it when you see it.

 

Notice:

This scheme must be carried out before starting QTP, otherwise it is invalid.

 

Summarize:

 

These two lectures mainly introduced the use of object mapping to solve the problem of unrecognized objects, as well as some matters needing attention. Of course, this is just the tip of the iceberg. There are thousands of cases where objects cannot be recognized. Different situations have different solutions, such as accessing the interface of the control itself, accessing custom objects through DotNetFactory, solving by writing a custom Dll dynamic link library, extending development through plug-ins, etc. I will not give examples here. .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443795&siteId=291194637