Adding more data types for a control
HCL OneTest™
UI provides a set
of control data types for data verification point. You can add more control
data types by extending the getTestDataTypes()
and getTestData()
APIs.
Before you begin
Java | .Net |
---|---|
java.util.Hashtable getTestDataTypes() | System.Collections.Hashtable GetTestDataTypes() |
ITestData getTestData(String testDataType) | ITestData GetTestData(string testDataType) |
Example
The following sample shows how to add a new control data type
Selected
Text
in Java™. You can add as many data types as you want in
the same manner.Note: Ensure that the key and value of hash are the same in the
hashtable returned by the GetTestDataTypes.
public class AnyProxy:BaseProxy
{
.
.
.
public java.util.Hashtable getTestDataTypes()
{
java.util.Hashtable result = super.getTestDataTypes();
result.put("Selected Text", "Selected Text");
return result;
}
.
.
public ITestData getTestData(String testDataType)
{
if (testDataType.equals("Text"))
return createTestDataList(getText()); // getText() method returns text value of the control
else
return super.getTestData(testDataType);
}
The following sample shows how to add a new data type in .Net:
Using Rational.Test.Ft.Vp;
public class AnyProxy:BaseProxy
{
.
.
.
public override System.Collections.Hashtable GetTestDataTypes()
{
System.Collections.Hashtable types = base.GetTestDataTypes() ;
types.Add("Selected Text", "Selected Text") ;
return types;
}
.
.
.
public override ITestData GetTestData(string testDataType)
{
ITestData testData = null ;
switch (testDataType)
{
case "Text":
testData = new TestDataText(((System.Windows.Forms.Control)theTestObject).Text) ;
break;
}
return testData;
}
}
What to do next
Selected Text
is available while creating a data verification point in
the control.