Qtp 简明教程

QTP - Smart Identification

有时,QTP 无法找到与识别的对象描述相匹配的任何对象,或者它可能会找到多个适合该描述的对象,然后 QTP 将忽略识别的描述并使用智能识别机制识别对象。

Sometimes, QTP is unable to find any object that matches the recognized object description or it may find more than one object that fits the description, then QTP ignores the recognized description and uses the Smart Identification mechanism to recognize the object.

QTP 的智能识别使用两种类型的属性 -

QTP’s Smart Identification uses two types of properties −

  1. Base Filter Properties − The basic properties of a particular test object class whose values cannot be changed without changing the essence of the original object.

  2. Optional Filter Properties − Other properties also assist in identifying the objects of a particular class whose properties are unlikely to change often but can be ignored if they are no longer applicable.

Enabling Smart Identification for an Object

Step 1 - 导航到“工具”→“对象识别”。对象识别对话框打开。

Step 1 − Navigate to "Tools" → "Object Identification". Object Identification dialog opens.

Step 2 - 选择环境、对象类并打开“启用智能识别”,如下所示 -

Step 2 − Choose the Environment, Object Class and Turn ON "Enable Smart Identification" as shown below −

qtp smart identification

Step 3 - 单击“配置”并选择基础和可选筛选器属性。

Step 3 − Click Configure and choose the base and Optional Filter Properties.

qtp smart identification 1

Step 4 - 在基础属性中添加除默认属性之外的属性,还可以添加/删除可选筛选器属性。请注意,相同的属性不能同时属于强制属性和辅助属性,然后单击“确定”。

Step 4 − Add Properties in Base Properties apart from the default one and also add/remove Optional Filter Properties. Please note that same properties cannot be a part of both Mandatory and Assistive Properties and click "OK".

qtp smart identification 2

Step 5 - 在对象存储库中添加该类型对象后,验证是否启用智能识别。智能识别已设置为 TRUE。在不需要启用智能识别的情况下,也可以将其设置为 False。

Step 5 − Verify if the Smart Identification is enabled after adding object of that type in the Object Repository. Smart Identification is set to TRUE. We can also make it False in case we do not want to enable Smart Identification.

qtp smart identification 3

Step 6 - 甚至可以通过在“文件”菜单的“设置”下应用测试脚本级别来禁用测试级别,如下所示:

Step 6 − We can even disable a test Level by applying at test script level under "Settings" of "File" Menu as shown below −

qtp smart identification 4

Step 7 - 如果根据步骤 6 禁用智能识别,它将在脚本执行期间不会对任何对象应用智能识别。

Step 7 − If the Smart Identification is disabled as per Step# 6 then it will not apply smart identification for any object during the script execution.

Step 8 - 如果使用关闭状态添加对象,则 QTP 将不会使用智能识别来进行识别,即使我们稍后已将其启用。

Step 8 − In case the objects are added with Smart Identification as Off, QTP will not use Smart Identification for recognizing in future, even though we have enabled it later.