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

TC中Add File & Compare File使用介绍

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

3Q$g~'a FBCz]0添加需要比较的文件有以下3种方法:51Testing软件测试网X#J"x&XSv [0K M
 
$KA s Yx ?0//1.Add files from the Files editor
G e2m4HE [ y'l-m)P0//2.Add files from the Project Explorer
pM6V@i"~wR#[0//3.Add files from scrīpts

YFG7pa&u2`,R0

G;lrpF NlQ W0在TC里,封装了好几个文件比较的方法,主要有以下几种:51Testing软件测试网7KQB:uNXq&z)D-J
//4.Comparing files by bytes
,lX |e:z?&pM0//使用正则表达式比较文件(RegExpr)51Testing软件测试网.aD{p3q,J+~\;X }
//5.Comparing files with variable parts51Testing软件测试网9WoM:NUZ P-d|Q

(?:R9g;M5` MH0具体使用如下:51Testing软件测试网ep"W*D%mvu3d3Uz8Y4k

c.yz j-|0procedure AddfileFromscrīpt;51Testing软件测试网"WG2P `S%t7{ `wA5|
begin51Testing软件测试网 Q2@l,z5H9{+E
  if not Files.Add('..\..\TestFile_old.txt', 'TestFile_old') then51Testing软件测试网'u1aPQ$J0d#pP%l
    Log.Message(Files.LastError);51Testing软件测试网 @l @%]r;OS TN
  if not Files.Add('..\..\TestFile_new.txt', 'TestFile_new') then51Testing软件测试网pq1Y?v"~
    Log.Message(Files.LastError);
2zz hr?9T*T*~0  if not Files.Add('..\..\TestFile_new_space.txt', 'TestFile_new_space') then51Testing软件测试网"MBNy3z
    Log.Message(Files.LastError);51Testing软件测试网)PgJ3lK}E|
end;

[e{?*x2j1W+qS0

3\HJls6b0//获取文件方式
8AHd jC1j4|K0//FileNameByIndex、FileNameByName、NameByIndex 、NameByFileName 、FileNamesList、NamesList
d9khT2U"Z SjJT0procedure GetFile;
#Gs,PT8c3d0begin
E9y~L2|sP\]0  showmessage(Files.FileNameByIndex(0));51Testing软件测试网0hn|8G6~ ol
end;51Testing软件测试网1k[.Bab^H

+A\j+z!nN|-j0//常用比较文件方式
*A4Q8` y)z6gas}0procedure ComparefileBytes;51Testing软件测试网u\a[:pB3c"c
begin51Testing软件测试网 EM V,MKC$m
  if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new')) then
B,ywSYcw Tb0    showmessage(files.LastError);
6q.r2s4~ }6R's(b0end;

Fs O7\#n HN9n-W051Testing软件测试网jz,yEx ?

//通过Hash值比较文件51Testing软件测试网 u*O}:X(m e)X$? j1t
procedure ComparefileHash;51Testing软件测试网-I\;i4~9qV
var Hash : OleVariant;//Hash记录两个文件的差异值
T;t0HB#al0BYM0begin51Testing软件测试网/C@ T:}2^6ez ^4C
  Hash := Files.CalculateHashValue(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'));51Testing软件测试网%L^0J4]'@!I8[H
  if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'),Hash) then51Testing软件测试网!`e6T+Y_YqX
    showmessage(files.LastError)51Testing软件测试网KY~B8KK
  else showmessage('The two files is equal!');
}1n8h a Q!lKn0end;

'L+mC ZNp;r$f0

6R-E8NRh2N0procedure Test_Sample;
4WD~Ei`?0begin
I%o9e `G`"F4ZW+GN0  Aliases.TCSampleForm.Drag(224, 17, 162, 0);
$wG4d6Xm0  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);51Testing软件测试网y`BH|(lG
end;

iV*A1cYA yaf)V0

TAG: Testcomplete TestComplete

 

评分:0

我来说两句

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

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

RSS订阅

Open Toolbar