在RFT中如何获取JComboBox中的所有项?

如果获取JcomboBox中的每一项元素?

 

下面的例子取到JcomboBox中的每一项,并进行单击操作:

 

startApp("ClassicsJavaA");

 

// Frame: ClassicsCD

tree2().click(atPath("Composers->Schubert->Location(PLUS_MINUS)"));

tree2().click(atPath("Composers->Schubert->Die schone Mullerin, Op. 25"));

placeOrder().click();

 

//Declare variables for list

ITestDataList nameList;

ITestDataElementList nameListElements;

ITestDataElement nameListElement;

 

//Frame: Member Logon

nameCombo().waitForExistence();

 

//Available test data types: {selected=Selected List Element,

//list=List Elements}

java.util.Hashtable ht = nameCombo().getTestDataTypes();

System.out.println(ht);

 

//Get all elements

nameList = (ITestDataList)nameCombo().getTestData("list");

nameListElements = nameList.getElements();

 

int listElemCount = nameList.getElementCount();

 

    for (int i = 0; i < listElemCount; i++)

    {

    nameListElement = nameListElements.getElement(i);

    System.out.println(nameListElement.getElement());

   

    // Click on each element

    nameCombo().click();

    nameCombo().click(atText(nameListElement.getElement().toString()));

    };

   

 

// Frame: ClassicsCD

classicsJava(ANY,MAY_EXIT).close();

 

 

代码中主要是通过getTestData("list")取到JcomboBox中的所有元素,返回的集合是ItestDataList类型的,然后再通过getElements方法取到ItestDataList这种类型集合中的所有元素,放到ItestDataElementList类型的对象中存储起来,接着就可以通过getElement方法访问对象中的每个元素了。

 

 

关于ItestDataList、ItestDataElementList的描述可参考RFT的帮助文档:

ITestDataList

All Superinterfaces:

ITestData


public interface ITestDataList
extends ITestData

Represents the elements in a list-type object for a verification-point operation. The elements in the list are encapsulated in an ordered list.

Since:

RFT1.0


Method Summary

 int

getElementCount()
          Returns the setting of the
elementCount property.

 ITestDataElementList

getElements()
          Returns the object that contains the elements in the list.

 boolean

getOrdered()
          Returns the setting of the
Ordered property.

 void

setElementCount(int count, boolean masked)
          Sets count of items in the list as an
UNmasked property of the list.

 void

setElements(ITestDataElementList elements)
          Defines the element set.

 void

setOrdered(boolean ordered)
          Sets the list to be compared in either an ordered or unordered fashion.

 

ITestDataElementList


public interface ITestDataElementList

Used by the ITestDataList interface to encapsulate the ordered set of generic elements that make up the desired list. This interface is not typically used directly, but instead is a shared implementation of a collection of generic elements without specific higher-level control attributes. When used relative to the ITestDataList interface, appropriate comparison attributes are available to control use of the list.

Since:

RFT1.0


Method Summary

 void

add(ITestDataElement element)
          Appends an element to the end of the list.

 void

add(ITestDataElement element, int atIndex)
          Inserts the specified element at the specified position in this list.

 ITestDataElement

getElement(int index)
          Returns the
ITestDataElement at the specified index.

 java.util.Vector

getElements()
          Returns an ordered vector of
ITestDataElement objects.

 int

getLength()
          Returns the number of elements that exist in the associated list.

 void

remove(int atIndex)
          Removes the element at the specified index from the list.

 void

removeAll()
          Removes all elements in the list.

 

ITestDataElement


public interface ITestDataElement

Encapsulates a generic element used in an ITestDataList. You should not use this interface directly outside the context of a list. You can access similar functionality by directly using the ITestData interface and specifying a property with an appropriate masking setting.


Method Summary

 java.lang.Object

getElement()
          Returns an element of a
list or set-test data container.

 boolean

getMasked()
          Returns
true if the associated element should be masked from comparison operations of the containing-list data.

 void

setElement(java.lang.Object element)
          Sets an element of a
list or set-test data container.

 void

setMasked(boolean masked)
          Specifies whether the associated element should be masked from comparison operations of the containing-list data.

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值