RFT处理表格(代码收藏三)
上一篇 / 下一篇 2008-06-17 13:59:10 / 个人分类:Rational
1208328177
- 自动化测试:
- 测试文档:
6.确定表中单元的值(内容)
import resources.TableTestHelper;
Guk.V,t0import com.rational.test.ft.*;51Testing软件测试网3~)a'k { d
import com.rational.test.ft.object.interfaces.*;
lV@?:y.d0import com.rational.test.ft.scrīpt.*;
L[4nlCt0import com.rational.test.ft.value.*;
m8J}!Kj
I6cW0import com.rational.test.ft.vp.*;
public class TableTest extends TableTestHelper51Testing软件测试网BR%_7R:Zd/E
{51Testing软件测试网:\,rW[ V
X3V^'v
public void testMain (Object[] args)51Testing软件测试网,iF2] K*A
{
7{E??]0startApp("TableTest");
// Browser: MS Internet Explorer
M"m|
|0Ck{A0// Document: Table Test Page: file:51Testing软件测试网$k!NA i8t UrP
//D:\Temp\TableTest.html
//Click on table to generate an object in the Object Map.
%pQ'e'Op
S'Y|"Z!w0Table_AutoNumber1().click(atCell(51Testing软件测试网 SY5Cq+]I
atRow(atIndex(1)), atColumn(51Testing软件测试网t*O&{k?T@]OD
atIndex(1))));
//Query object to find out what kind of data it has.51Testing软件测试网c L
ccCx
X
Ep
System.out.println (Table_AutoNumber1().getTestDataTypes());
//Declare variable for table.
+W;w,S#b
ZEN W0ITestDataTable myTable;51Testing软件测试网8O%~g:M7F,n9Aa1S
myTable = TestDataTable)Table_AutoNumber1().getTestData("grid");
//Print out total rows & columns.51Testing软件测试网v6XpQ Faq
System.out.println ("Total Rows: " + myTable.getRowCount());51Testing软件测试网cl_-SC(s,yLF
System.out.println ("Total Cols: " + myTable.getColumnCount());
//Print out cell values.
U#sMYRH7D0for (int row =0;row < myTable.getRowCount();row++)
3|2v[wyJBg0{
wr/ArZ3wR{0for (int col = 0;col < Table.getColumnCount();col++)51Testing软件测试网C(j'VXOSR Kf&tO
{
9V;Z(U-P'_0System.out.println("Value at cell (" + row+ "," + col+")
H*v6}*v4me)Fd0is: " + myTable.getCell(row,col));51Testing软件测试网&L$H%b a M
}
:y2DpuK#d&?0}
Browser_htmlBrowser(Document_TableTestPage(),MAY_EXIT).close();51Testing软件测试网e~D}eDx%S
}
W{&E-Ngf0}
7.使用getTestData方法获取表格单元的值
import resources.GetGridDataExampleHelper;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.scrīpt.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
public class GetGridDataExample extends GetGridDataExampleHelper
{
public void testMain (Object[] args)
{
// Turn off Log Viewer for this example
setOption(IOptionName.BRING_UP_LOGVIEWER, false);
// Start Classics Java Application
startApp("ClassicsJavaA");
// Navigate to Existing Order Grid
jmbMenuBar().waitForExistence();
jmbMenuBar().click(atPath("Order"));
jmbMenuBar().click(atPath("Order->View Existing Order Status..."));
// Frame: View Order Status
nameComboBComboBox().click();
nameComboBComboBox().click(atText("Claire Stratus"));
okstatuslogon2Button().click();
// Wait for table to be created
existingTableTable().waitForExistence();
// Get the data for the table,第一步:从控制器从取得数据
ITestDataTable orderTable;
orderTable
(ITestDataTable)existingTableTable().getTestData("contents");
// Display the available data types for the grid, total rows and
// columns.通过getTestDataTypes方法告知控制器哪些数据是可利用有效的
System.out.println ("Available Data Types: " +
existingTableTable().getTestDataTypes())
System.out.println ("Total Rows in table : " +
orderTable.getRowCount());
System.out.println ("Total Cols in table : " +
orderTable.getColumnCount());
// Cycle through all rows(getColumnCount,getColumnCount方法开始循环起点为0)
for (int row=0; row < orderTable.getRowCount();++row)