不谋万世者,不足谋一时;不谋全局者,不足谋一域。君子敏于事而慎于言 新浪微薄:土司阿哈

RFT处理表格(代码收藏三)

上一篇 / 下一篇  2008-06-17 13:59:10 / 个人分类:Rational

1208328177
  • 自动化测试:
  • 测试文档:

6.确定表中单元的值(内容)51Testing软件测试网j,K!yGuM#ptk

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.*;

'Egs5](e'O0

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");

d@2w0Ql`0

// Browser: MS Internet Explorer
M"m| |0Ck{A0// Document: Table Test Page: file:51Testing软件测试网$k!NA i8t UrP
//D:\Temp\TableTest.html
51Testing软件测试网a I'P gR3ku.v$W"Y

//Click on table to generate an object in the Object Map.
%p Q'e'Op S'Y|"Z!w0Table_AutoNumber1().click(atCell(51Testing软件测试网 S Y5Cq+] I
atRow(atIndex(1)), atColumn(51Testing软件测试网t*O&{k?T@]OD
atIndex(1))));

)S.o%B,kBZf0

//Query object to find out what kind of data it has.51Testing软件测试网cL ccCx X Ep
System.out.println (Table_AutoNumber1().getTestDataTypes());
51Testing软件测试网4KCawy

//Declare variable for table.
+W;w,S#b ZENW0ITestDataTable myTable;51Testing软件测试网8O%~g:M7F,n9Aa1S
myTable = TestDataTable)Table_AutoNumber1().getTestData("grid");

9J7\ S#fH k1V9b!w0

//Print out total rows & columns.51Testing软件测试网v6XpQFaq
System.out.println ("Total Rows: " + myTable.getRowCount());51Testing软件测试网cl_-SC(s,yLF
System.out.println ("Total Cols: " + myTable.getColumnCount());
51Testing软件测试网r'M/R*e%b2_~

//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}

1{ qWw N#`6yC0

Browser_htmlBrowser(Document_TableTestPage(),MAY_EXIT).close();51Testing软件测试网e~ D}eDx%S
}
W{&E-Ngf0}
51Testing软件测试网x!|!F7q+a

7.使用getTestData方法获取表格单元的值

x&^0b)u7irx ?0

import resources.GetGridDataExampleHelper;

)~R \:y/Wt0Y0

import com.rational.test.ft.*;

W2O}&N Y#oJ0

import com.rational.test.ft.object.interfaces.*;

:J a LI]&W3`/uoo0

import com.rational.test.ft.scrīpt.*;

2DH4hL/_`6`2e,_B1Y'f0

import com.rational.test.ft.value.*;

;L9sT*`Zr E-kQE0

import com.rational.test.ft.vp.*;

/z/T4E-z#npi1Lu*B'_q0

public class GetGridDataExample extends GetGridDataExampleHelper51Testing软件测试网%QYT\#w+XDq

{

?vK*?c py:J+F0

public void testMain (Object[] args)

&PSS^3\n | VG {0

{

I(W"|~,O g4}]7kT0

 

_ A.Zp l L^R0

// Turn off Log Viewer for this example51Testing软件测试网?.\ e |!eLO7oS4c

setOption(IOptionName.BRING_UP_LOGVIEWER, false);

L-x3@PN e0

 

,cY2D1d7iF&HC0

// Start Classics Java Application

4F^x'^B9U2}9L0

startApp("ClassicsJavaA");51Testing软件测试网M7V ]0Q8vE$IF+\

 

s j ~j-S+wZ0

// Navigate to Existing Order Grid51Testing软件测试网cf2WTs"j j h

jmbMenuBar().waitForExistence();51Testing软件测试网2V mAQC1G1ZI0}.f

jmbMenuBar().click(atPath("Order"));51Testing软件测试网n`(}b.J3`

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

&z$P I/pA O^0

 51Testing软件测试网8j8l"UD jhUA

// Frame: View Order Status

]$D @gU]5gA0

nameComboBComboBox().click();51Testing软件测试网I(a0bNsv

nameComboBComboBox().click(atText("Claire Stratus"));51Testing软件测试网L:tJk Ya:Y

okstatuslogon2Button().click();

A"pm(~MRs7N7d9{ j0

 51Testing软件测试网 ru@!IT7fT*Y

// Wait for table to be created51Testing软件测试网`_(_XheF

existingTableTable().waitForExistence();

bDw*KK3u ^0

 51Testing软件测试网2o]*S7qhP!e

// Get the data for the table第一步:从控制器从取得数据51Testing软件测试网!sat{Y8K C&y1n

ITestDataTable orderTable;

O8AU0[Bo0

orderTable

5P`N,xY} `+I0

(ITestDataTable)existingTableTable().getTestData("contents");

i0?9y?\"F0

 51Testing软件测试网/sqVFzO z k

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

Gl J.u]?:}2g(Ft:i0

// columns.通过getTestDataTypes方法告知控制器哪些数据是可利用有效的51Testing软件测试网t7`n5K6z3p

System.out.println ("Available Data Types: " +

3[:U(WB.|~0

existingTableTable().getTestDataTypes())

Yg0J e"m3dVOD0A7C0

System.out.println ("Total Rows in table : " +

\&V7X1\;|-g1qf.H8tR*W-V0

orderTable.getRowCount());

El#I+uM/j0

System.out.println ("Total Cols in table : " +51Testing软件测试网;EU~h'hv

orderTable.getColumnCount());

6_:c lp#}*|)["R!qv.s0

 51Testing软件测试网/zJl7y;B

// Cycle through all rowsgetColumnCountgetColumnCount方法开始循环起点为051Testing软件测试网8J2Wq+`W

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

H&ii^ ok6}[0

{

v,aWX3]V`P$R0

// Cycle through all columns

4u+vr;s/bu*Ulj0

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

IhDG"f*C-s,L0

{51Testing软件测试网;_ K,Q.~3tKP5Z)t

// Print out values of cells at (row,col) coordinates51Testing软件测试网h%Vtuc-}1]

System.out.println ("Row " + row + ", " +

b*B3ZQ,x5t0e0

orderTable.getColumnHeader(col) + ": "51Testing软件测试网3H1qqJ?0e^v#hP

+orderTable.getCell(row,col) );51Testing软件测试网1h6m'@X*hZv

}

;Y4x]*wlI-p8ua0

}51Testing软件测试网-VEw x&h+Ne

// Close the frame

.fl(x+n.j0{7e;T `+};Sf0

closeorderButton().click();51Testing软件测试网PuQ|o"M

// Shut down Classics Java Application51Testing软件测试网_,ui`6TmYP8o

ClassicsJavaFrame(ANY,MAY_EXIT).close();

F/{ko8A/g d?0

}51Testing软件测试网|"ZTn3Na[

}51Testing软件测试网#P;N C5~;} d

8.传递参数给callscrīpt方法51Testing软件测试网lW!K.m*CN#i

//没有参数   callscrīpt("TheCalled");

7w)MKB4G5p }S0

//数组参数

M dm/w'T(}q}:uJ\0

String[] dataToPass = new String[4];

-TI&Q3g5M0

callscrīpt("TheCalled",dataToPass);51Testing软件测试网x!]5[J9?9SU.s3K&Y

//对象参数

m0Np:W WXU0a0

Object[] ōbjdataToPass = new Object[4];51Testing软件测试网K ~5R?J-bU

callscrīpt("TheCalled",objdataToPass);

mPZV&H `"y0

TAG: Rational

 

评分:0

我来说两句

Open Toolbar