在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