Adding more control properties
HCL OneTest™
UI provides a set
of control properties for access and property verification. You can add more
control properties by extending the getProperties()
and getProperty()
APIs.
Before you begin
Java | .Net |
---|---|
java.util.Hashtable getProperties() | System.Collections.Hashtable GetProperties() |
Object getProperty(String propertyName) | object GetProperty(string propertyName) |
Example
ToolTipText
.
You can add as many properties as you want in the same manner. The following sample shows how to add a new property in 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);
}
}
The following sample shows how to add a new property in .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 ;
}
What to do next
ToolTipText
is added to the control. You can verify
this by running the getProperty("toolTipText")
API on the
control.