添加更多的控件属性

Functional Tester 提供一组用于访问的属性验证的控件属性。通过扩展 getProperties()getProperty() API,您可以添加更多的控件属性。

开始之前

您可以扩展 表 1 中列出的代理方法:
表 1. 可扩展的代理方法
Java .Net
java.util.Hashtable getProperties() System.Collections.Hashtable GetProperties()
Object getProperty(String propertyName) object GetProperty(string propertyName)

示例

以下样本添加新的属性 ToolTipText。 您可以采用同样的方式来添加任意数量的属性。

以下样本显示如何以 Java™ 语言添加新的属性:

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

public class someProxy extends baseProxy
{
 .
 .
 public java.util.Hashtable getProperties()
 {
    java.util.Hashtable properties = super.getProperties();
    try
    {
	properties.put("toolTipText", getTooltipText());
    }
    catch (Throwable e)
    {
    } // in the odd case we can't get the artifical properties, just ignore them.
    return properties; 
 }
 .
 .
 .
 public Object getProperty(String propertyName)
 {
    if (propertyName.equals("toolTipText"))
	return getTooltipText();
    return super.getProperty(propertyName);
 } 
}

以下样本显示如何以 .Net 形式添加新的属性:

using Rational.Test.Ft.Domain;

public class AnyProxy:BaseProxy
{
     .
     .
     .
    public override System.Collections.Hashtable GetProperties()
    {
        System.Collections.Hashtable propertyTable = base.GetProperties(); 
        
         if( !propertyTable.Contains("ToolTipText"))
         {
	object text = GetToolTipText();
	if (text != null)
	  propertyTable.Add("ToolTipText", text );
         }
         return propertyTable;
    }
    .
    .
    .
   public override object GetProperty(string propertyName)
   {
       object propertyValue = null ;
       if (propertyName == "ToolTipText" )
       {
         propertyValue = GetToolTipText();
       }	
       else
       {
         propertyValue = base.GetProperty(propertyName) ;
       }
       return propertyValue ;
   }

下一步做什么

成功开发和部署此代理代码后,将新属性 ToolTipText 添加到控件中。您可以通过在控件上运行 getProperty("toolTipText") API 来验证此属性。

反馈