在RFT中如何获取JTable中的所有数据?

本文介绍了一种在RFT中从JTable组件获取所有数据的方法,包括遍历表格的每一行和每一列,以及读取具体单元格的内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

在RFT中如何获取JTable中的所有数据?

 

public void testMain(Object[] args)

{

 

//Start Classics Java Application

startApp ( "ClassicsJavaA" );

 

//Navigate to Existing Order Grid

jmb().click(atPath ( "Order" ));

jmb().click(atPath ( "Order->View Existing Order Status..." ));

 

// Frame: View Order Status

nameComboB().click();

nameComboB().click(atText ( "Claire Stratus" ));

ok().click();

 

// Frame: View Existing Orders

existingTable().click(atPoint (172,92));

 

//Get the data for the table

ITestDataTable orderTable = (ITestDataTable)existingTable().getTestData( "contents" );

 

//Display the available data types for the grid, total rows and columns.

System. out .println ( "Available Data Types: " + existingTable().getTestDataTypes ());

System. out .println ( "Total Rows in table : " + orderTable.getRowCount());

System. out .println ( "Total Cols in table : " + orderTable.getColumnCount());

 

          // Cycle through all rows

          for ( int row=0; row < orderTable.getRowCount();++row)

          {

              // Cycle through all columns

              for ( int col=0; col < orderTable.getColumnCount();++col)

              {

                  // Print out values of cells at (row,col ) coordinates

                  System. out .println ( "Row " + row + ", " + orderTable.getColumnHeader (col) + ": " +orderTable.getCell (row,col) );

                    }

            }

// Close the frame

close().click();

 

// Frame: ClassicsCD

classicsJava( ANY , MAY_EXIT ).close();

}

}

 

 

控制台输出:

Available Data Types: {contents=表内容, visible contents=可见表内容, selected=选中的表单元格, visible selected=选定可见表单元格}

Total Rows in table : 1

Total Cols in table : 7

Row 0, ORDER ID: 7

Row 0, ORDER DATE: 3/11/98

Row 0, STATUS: Order Initiated

Row 0, COMPOSER: Bach

Row 0, COMPOSITION: Brandenburg Concertos Nos. 1 & 3

Row 0, QUANTITY: 5

Row 0, TOTAL: 84.9500

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值