修改控件的识别属性和权重

Functional Tester 使用识别属性来唯一标识控件。为不同的识别属性分配不同的识别分析权重。Functional Tester 使用这些值和权重来识别回放期间的控件。您可以定制最适合正在测试的控件的识别属性和权重。

开始之前

要以扩展 表 1 中列出的方法:
表 1. 识别属性的扩展方法
Java .Net
java.util.Hashtable getRecognitionProperties() System.Collections.Hashtable GetRecognitionProperties()
int getRecognitionPropertyWeight(String propertyName) int GetRecognitionPropertyWeight(String propertyName)
注: 使用 Functional Tester对象库功能,您还可以将所有控件的识别属性和权重具体化为 XML 文件。有关对象库的更多信息,请参阅 Functional Tester 帮助。

以下 Java™ 样本添加了新属性 ".priorLabel" 作为附加的识别属性。

示例

import com.rational.test.ft.domain.*;

public class someProxy extends baseProxy
{
 .
 .
 public java.util.Hashtable getRecognitionProperties()
 {
    java.util.Hashtable properties = super.getRecognitionProperties();
    properties.put(".priorLabel", getPriorLabel());
    return properties;
 }
 .
 .
 .
 public Object getRecognitionPropertyWeight(String propertyName)
 {
    if (propertyName.equals(".priorLabel"))
	return 60;
    return super.getRecognitionPropertyWeight(propertyName);
 } 
}

以下 .Net 样本添加新属性 ".priorLabel" 为附加的识别属性。

using Rational.Test.Ft.Domain;

public class AnyProxy:BaseProxy
{
     .
     .
     .
    public override System.Collections.Hashtable GetRecognitionProperties()
    {
        System.Collections.Hashtable properties= base.GetRecognitionProperties(); 
	properties.Add(".priorLabel", GetPriorLabel() );
        return properties;
    }
    .
    .
    .
   public override object GetRecognitionPropertyWeight(string propertyName)
   {
       if (propertyName == ".priorLabel" )
            return 60; 
       return base.GetRecognitionPropertyWeight(propertyName) ;
   }

下一步做什么

成功开发和部署此代理节点后,为控件添加新的识别属性 ".priorLabel",属性权重为 60。通过在对象映射编辑器中查看识别选项卡,您可以验证此识别属性。

反馈