Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

In-depth Analysis of QucikTest Test objects

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Through the introduction and operation of the previous series of QuickTest blog posts, we have a certain understanding of QuickTest. This blog article has an in-depth understanding and analysis of the objects under QuickTest through examples with pictures and texts.

1. Working principle of QuickTest

From the previous blog articles about QuickTest, you learned that QuickTest classifies recorded test objects, such as standard Windows dialog boxes (Dialog), Web buttons (WebButton), and so on. The repository where QuickTest stores objects and object properties is called an object library (Repository). When QuickTest records the application under test, the objects involved in the recording process are added to the QuickTest object library.

When QuickTest records an object, QuickTest attempts to record the properties and property values of the object and store them in the object library. For each test object, there is a list of properties and attribute values in the QuickTest object library that corresponds to it. In the list of object properties, QuickTest will select some properties, and the combination of these attributes must be able to uniquely describe (mark) the test object. During the playback of the QuickTest test script, the object recorded in the object library (or the combination of multiple attribute lists) is compared with the objects in the application under test during playback. If a matching object is found, then press the recording operation of the recording process to make the matching object in the application under test perform some operations, such as Set or Click, etc.

two。 First acquaintance of the test object

QuickTest test object library is a collection of objects and object properties. QuickTest uses objects and object properties to represent objects in an application. Each test object recorded by QuickTest includes the following two items:

A list of properties that uniquely identify the object.

The action method (action) performed on the object during QuickTest recording.

Learning QuickTest test objects also needs to distinguish two important concepts: test objects and run-time objects.

Test object (Identification Properties): the object in the application under test recorded during QuickTest recording is called the test object. QuickTest uses test objects to mark objects in the application under test and stores the object properties and property values that help QuickTest identify and check objects in the application under test during a run (playback) session.

Runtime object (Native Properties): the object that is actually running during the application running (playback) session.

When you add an object to the object library, QuickTest takes the following steps:

Record the QuickTest object and create a corresponding test object that corresponds to the object in the application under test.

Read the current value of the object property in the application, and then store the property and the list of property values in the object library with the test object.

Determine the name of the test object (typically using the value of an important property of the test object).

QuickTest records the actions performed on the test object during recording in the test script.

Take the Flight booking system provided by QuickTest as an example, the test scenarios are as follows:

Table Test scenario 1

Operation

data

Expected result

Scenario 1

1. Enter user name

two。 Enter password

3. Click OK

Correct data

User name / password

Mercury/mercury

Log in to the system correctly

As shown in the figure, in the process of recording scenario 1, when you click the Agent Name input field and enter Mercury, QuickTest marks the operation object as the WinEdit test object, stores the attributes and attribute values of the object in the object library, and selects an attribute value (Agent Name) from the list of test objects as the name of the WinEdit test object. QuickTest also records the Set methods executed on the WinEdit object during recording in the test script. Right-click the Agent Name object in the keyword view and select "Object Properties..." To open the object properties dialog box

Object attribute

As shown in the figure, the script displayed in the expert view after the recording of scenario 1 is complete.

Expert view

When playing back a test script, QuickTest identifies the objects in the application by recording the description of the test object in the object library (a set of properties and property values that uniquely identify the test object). A list of test objects and their properties and property values is stored in the object library. During the playback of the test script recorded in scenario 1, QuickTest finds the WinEdit object in the object library. QuickTest looks for an object in the called application that is consistent with the WinEdit object in the object library, which is WinEdit, and the properties and attribute values include: nativeclass=Edit,attached text=Agent Name. When a matching object is found, the object executes the Set operation method.

If the key properties and property values (or multiple properties and values) of the object in the called application are different from the properties and values used to identify the object in the QuickTest object library, the test script fails during playback. Therefore, when the property value of the object in the application changes, the property value of the test object in the object library should be modified accordingly, which can ensure that the recorded test script can be played back successfully.

Note:

In some cases, QuickTest can use intelligent identification mechanisms to identify objects even if the values of some attributes of the object have changed. However, if you know that the property value of a particular object has changed, try to correct the property or property value of the test object so that QuickTest can identify the object based on its basic object description.

3. QuickTest object library

Usually in the process of QuickTest automation, the test objects are saved in the object library. QuickTest object library is divided into local object library and shared object library. Where do you want to choose to save the object? Let's first look at the comparison between different test scenarios.

Table Test scenario 1

Operation

data

Expected result

Scenario 1

1. Enter user name

two。 Enter password

3. Click OK

Correct data

User name / password

Mercury/mercury

Log in to the system correctly

Table Test scenario 2

Operation

data

Expected result

Scenario 2

1. Enter user name

two。 Click OK

Correct data

User name

Mercury

Prompt to enter the error message of the password

What are the similarities between the recording of scene 2 and the previously recorded scene 1? What are the similarities and differences?

What they have in common is that both scenes operate on the object AgentName and OK objects, and both record them in the object library. The difference is that in scene 1, because Password is also manipulated during recording, Password objects are also stored in the object library. Should we do some thinking at this time? Whether readers are thinking about the same question. Now that AgentName and OK objects exist in both scenes, can two objects in scene 1 be called and used by scene 2? The answer is yes. This is the local object library and shared object library that we will talk about next.

Local object library: each test scenario (Action) has its own object library, which is called the local object library. So what object library did previously recorded scripts use? Local object library.

Shared object library: generally speaking, it is an object library shared by multiple test scenarios (Action). Combined with the Action learned earlier, multiple Aciton share an object library, which is called a shared object library.

Are there any similarities and differences between the local object library and the shared object library in addition to the differences in definition?

Local object library: it is associated with Action, and the local object library mainly stores data in files ObjectRepository.bdb and Resource.mtr. Each time a new Action is created, the corresponding local object library is automatically created, and these files are created and generated.

Shared object libraries: unlike local object libraries, multiple Action can share a single object library-- shared object libraries. Shared object libraries can end with a Tsr suffix. In the testing framework of complex business systems, it is recommended to use shared object libraries. Similarly, because the business is complex and the management of the object library is unreasonable, it will result in the redundancy of the object library, the complex maintenance work in the later stage, the slow running speed of Action and so on.

Therefore, when designing and creating test scripts, you must first consider how to manage test objects during recording. Whether to use local object libraries or shared object libraries. So when to use the local object library? When to use the shared object library?

Local object libraries are recommended for the following situations:

When creating a single action test script.

When you do not need to modify object properties frequently.

Shared object libraries are recommended for the following situations:

Use keywords to drive testing techniques.

When multiple tests contain (create) multiple test scripts, interfaces, or object settings.

You need to maintain the properties of the test object frequently or update the properties of the test object regularly.

Often conduct multiple tests or regularly make "Insert Copy of Action" or "Insert Call to Action".

Note:

If there is no special explanation in the remaining sections of this blog, they are all aimed at the local object library.

Schedule 1 of this post lists the different functions and features of the object library window and the object library manager for object library management.

3.1 object Library window

The object Library window displays the recorded objects and their properties during the recording of the script. The objects recorded throughout the test are displayed in a tree structure in the object Library. In the object Library, you can use the object Properties dialog box to view or modify the properties of any test object in the library, or add a new object to the library. This blog still takes the recorded aircraft booking system as an example to explain the "object Library" window.

Object Library window

The figure shows the object library formed after recording the completion of the aircraft booking system (Flight). Click the object library icon in the QuickTest test toolbar

Or click on the menu bar [Resource]-[Object Repository … .] Open the object library of the current test script.

Object library

On the left side of the object library window are the objects captured during the recording of the test script (the objects are shown in a tree).

The top right side of the object library window (Object Properties) displays information about the properties of an object:

Name (Name): the name that QuickTest assigns to the test object.

Class (Class): the class to which the object belongs.

Object library (Repository): object library type (local library or shared library).

The lower right part of the object library window (Test Object details) shows the detailed properties and property values of an object.

Description property (Description properties): the Description property and its value are used to identify the object during the running session. Here you can add and remove description properties for maintenance test objects.

QuickTest uses the description property to determine the test object. If the object cannot be recognized during QuickTest playback, the object in the application under test can be recognized by adding, modifying or deleting the description attribute.

Sequence identification code (Ordinal identifier): the sequence identification code is represented in numerical form, which can be distinguished from other identical objects in the application under test by maintaining the order and position of the sequence identification code (the same object means that the attributes and attribute values of multiple objects are the same).

Additional information (Additional details): during the playback of the test script, intelligent identification can be enabled if the attribute description of the test object in the object library cannot uniquely determine the object in the application under test. Specify whether QuickTest forces intelligent recognition to be enabled by setting smart recognition to True or False.

3.2 object Properties in the object Library window, you can view the object Properties of objects stored in the object Library. You can view information about any test object in the object library through object Properties.

Note:

This section only explains the "object properties" of existing objects in the object library. However, it is not stored in the object library, and the "object properties" of the object will be explained in subsequent articles.

As shown in the figure, in the object library of the plane booking system (Flight) (test scenario 1) recorded for this blog post, select the object property box (Object Properties) after the Agent Name object. The various components of the object properties have been explained in detail in the object library window and will not be repeated here.

Object attribute

4. Edit and modify object properties

As the object under test (application or Web site) changes, the object in the original recorded test script may have changed in the newly released Build. If you do not make changes to the corresponding test objects in the object library, the playback of the test script is bound to fail. Therefore, when the test object has changed in the newly released Build, it is necessary to maintain the properties or attribute values of the corresponding test object in the object library.

Suppose, after recording the test scenario 1 (aircraft booking system (Flight) test script, a new Bulid is released, and in the new version, the property value of the "attached text" property of the Agent Name object has changed from "Agent Name" to "Name". Due to the change in the value of its object property, the test script stops at the "Agent Name" step during playback, pops up an error message and stops running the test script.

What should I do when there is an error message? A common approach is to maintain object properties in the object library.

1. As shown in the figure, open the object library for test scenario 1. Select the "Agent Name" object in the object library window object tree. On the right side of the object library window, click the left mouse button in the "attached text" property value area of the description property (Description properties), and its property value area becomes editable. Change the "attached text" property value from "Agent Name" to "Name". Then play back the test script after modifying the properties of the object, and you can observe the successful playback of the test script.

Modify object properties

two。 As shown in the figure, in addition to maintaining the properties of the object as shown in step 1, you can also change the properties of the object by finding and replacing. For example, the value of the "attached text" attribute in step 1 is changed from "Name" to the original "Agent Name". Click the find\ replace icon in the object library window toolbar, pop up the find\ replace window, fill in the attributes and values of the corresponding search objects and the attribute values of the corresponding attributes after replacement, click replace, and you can observe that the value of the "attached text" attribute has been changed from "Name" to the original "Agent Name".

Find / replace object properties

Note:

If you want to find an exact match for the word you enter when searching, select "Match whole word".

Select "Match case" if you want to be case-sensitive when searching.

Sometimes, the playback of the test script fails, not because the objects in the original recorded test script have changed in the newly released Build. However, because of the attribute description of the object in the previous object library, the tested object can not be uniquely determined in the newly released application under test. In this case, you need to add a property description of the object. The following examples are given.

1. As shown in the figure, the test script fails to play back in the newly released Bulid because the existing properties of an object are not sufficient to identify or label the object in the new bulid. You can maintain test objects by adding object properties. In the object properties window, click the other properties of the pop-up object to add additional properties and property values for the selected object. After adding and debugging the test script, you can see that the test script is played back successfully.

Add attribute

5. Add objects to the object library

If you need to adjust the train of thought of test script verification. Scenario 1 and scenario 2 are used in the blog post to adjust the recording order of the test scene, and test scenario 2 is recorded first. During the recording process of scene 1, there are only more operations on Password objects than scene 2. Can we do something based on scene 2 instead of recording scene 1, so as to meet the needs of scene 1? After you have learned to add object knowledge in this section, you can realize the requirement from scenario 2 to scenario 1.

Suppose the verification content of a scenario is to open the login box of the aircraft booking system, enter the user name and password, and click cancel instead of OK. The purpose is to verify whether you can exit normally. So how to adjust the existing test scripts? Do you need to re-record the script? This can be done by adding objects to the object library and adjusting the order of keywords in the keyword view.

There are many ways to add objects, mainly in the following two ways:

Add objects using "Active Screen".

Add objects using the object library.

1. As shown in the figure, right-click in the location of "Cancel" in the "Active Screen" window, and click "View/Add Object" in the right-click list.

Add object

two。 As shown in the figure, the first step is to click "View/Add Object" and then pop up the "Object Selection" dialog box. "Object Selection" dialog box to select the added object (Cancel).

Select object

3. As shown in the figure, click [ok] in the Object Selection dialog box to open the Object Properties window.

Object attribute

4. As shown in the figure, click the [Add to Repository] button to see that [Add to Repository] becomes [View in Repository].

Object attribute

5. As shown in the figure, click [View in Repository] to enter the object library. In the object library, you can observe that there are more "Cancel" objects in the object tree on the left side of the object library.

Object library

6. As shown in the figure, in the keyword view, select the row of the "OK" Operand, you can see the drop-down arrow to the right of the "OK" keyword, and select the "Cancel" object in the drop-down object list.

Change Operand

7. As shown in the figure, replace the "OK" object with the "Cancel" object. Play back the test script, you can observe the aircraft booking system during the playback process, enter the user name and password, and click cancel instead of OK.

Keyword view

6. Delete object

In addition to editing, modifying and adding objects in the object library, you can also delete objects simply.

Deleting an object is easier to understand than adding an object. The test scenario 1, which has been used by the blog, is compared with the test scenario 2, which only records the Password object and the operation on it. If you do not record scene 2, is it possible to change from scene 1 to scene 2? The answer is yes, you can change from scenario 1 to scenario 2 by deleting the Password object in scenario 1 and adjusting the test script for scenario 1 in the keyword view.

1. As shown, open the scene 1 object library and select the Password object in the object tree on the left side of the object library.

Select object

two。 As shown in the figure, right-click the Password object, select Delete, and delete the Password test object.

Delete object

3. Open the scene 1 keyword view, as shown in the figure, and in the keyword view, delete the action line where the Password object is located.

Add Operand

4. Save scenario 1 as a test script for scenario 2, and the change from scenario 1 to scenario 2 has been completed. The recording time of scene 2 is saved and the testing efficiency is improved.

7. Schedule 1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report