技术只有在交流分享中才能更上一层楼! 复杂的事简单做。 简单的事认真做。 认真的事重复做。 重复的事创造性做。

TC中Add File & Compare File使用介绍

上一篇 / 下一篇  2008-05-02 12:02:02 / 个人分类:TestComplete

51Testing软件测试网u'~3w Hz.zV?R

添加需要比较的文件有以下3种方法:51Testing软件测试网2rWH I TH
 
6G@$R%VLj:W\0//1.Add files from the Files editor
i9Lt%SX0//2.Add files from the Project Explorer51Testing软件测试网%Fj WW iw
//3.Add files from scrīpts51Testing软件测试网$H+t z RA t3M,J9b"U

#jC6w@1um0在TC里,封装了好几个文件比较的方法,主要有以下几种:
Y~LS }z5]%n0//4.Comparing files by bytes
H%u.k@~ G,J/C0//使用正则表达式比较文件(RegExpr)51Testing软件测试网d3epv,YH7G
//5.Comparing files with variable parts51Testing软件测试网6l%}d#o)Y5\

&y H Tz1L*UEY(JM0具体使用如下:

G&JW zm S*adl0

Hw5@*UU$\cyNN+o0procedure AddfileFromscrīpt;
\P"?7Tc*hW8Em:k0begin
T*t R;wa-nLk;x0  if not Files.Add('..\..\TestFile_old.txt', 'TestFile_old') then51Testing软件测试网7D ^5gU3h va
    Log.Message(Files.LastError);
$K-W0hj2d0  if not Files.Add('..\..\TestFile_new.txt', 'TestFile_new') then
S EC J"[cw0    Log.Message(Files.LastError);51Testing软件测试网 p4Sfg;eyu7H B3O
  if not Files.Add('..\..\TestFile_new_space.txt', 'TestFile_new_space') then
| |)b;ts;D0    Log.Message(Files.LastError);
)] KRr~P#L0end;51Testing软件测试网){-[#if"u(I

51Testing软件测试网pT6L"m&n6Qxh g

//获取文件方式51Testing软件测试网v \&m'n!L-B6l
//FileNameByIndex、FileNameByName、NameByIndex 、NameByFileName 、FileNamesList、NamesList51Testing软件测试网*yl p&d*^cw:R
procedure GetFile;
+H&y1enhb)H[&cp0begin
,b6o7U I8Z3ZpF_0  showmessage(Files.FileNameByIndex(0));
EYW8l[w5Y0end;51Testing软件测试网\j0R_E\,U/J!B*g

51Testing软件测试网KA3c6kU*@(sk o*r9b1f

//常用比较文件方式
5^3jl)r0_{CL0procedure ComparefileBytes;
-p9sD6H K PJ?&]0begin
$e"c/W1S e&q-?0  if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new')) then
/m4oOG2hF\6k0    showmessage(files.LastError);
0r)V'kK7f0end;51Testing软件测试网}UPy8Mscz

%J~ Gp` p0//通过Hash值比较文件51Testing软件测试网;W Q Hz-C
procedure ComparefileHash;
GTRO~*}0var Hash : OleVariant;//Hash记录两个文件的差异值51Testing软件测试网Bk8D'?|g"~v+W:s1Ah
begin
~8t*OI6q5Y~0  Hash := Files.CalculateHashValue(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'));
6wR%E K!q aL1s'x&wUt0  if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'),Hash) then
T#OmB0W|._T&N0    showmessage(files.LastError)
XJt/FH0  else showmessage('The two files is equal!');51Testing软件测试网3J qw-w5Ys
end;

ce&wb.W.P+j@051Testing软件测试网$[H Jg-hP lsn

procedure Test_Sample;
`4R gU_0begin51Testing软件测试网r?X/x9rV
  Aliases.TCSampleForm.Drag(224, 17, 162, 0);
2D*Q&dmd;{0  Aliases.TCSampleSys.Process('Explorer').Window('Shell_TrayWnd').Window('ReBarWindow32').Window('MSTaskSwWClass', '运行应用程序').Window('ToolbarWindow32', '运行应用程序').CheckItem('TestComplete - C:\Documents and Settings\temp\桌面\hzr-TechED\TCSamples\TCSamples', -1, false);
Q#R;?n k/EW0end;

-st:x4m5^}w0

TAG: Testcomplete TestComplete

 

评分:0

我来说两句

日历

« 2024-05-05  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 22120
  • 日志数: 36
  • 文件数: 1
  • 建立时间: 2007-11-13
  • 更新时间: 2008-09-21

RSS订阅

Open Toolbar