UFT常识

来源:互联网 发布:网络女神成路人 贴吧 编辑:程序博客网 时间:2024/05/21 12:42

UFT也用了一段时间了,自己竟然还老犯同样的错误,遇到同样的问题。自己还不能单独解决,对不起导师,对不起自己。下面对UFT中的一些基本问题总结一下。

1.关于DataTable

导入:DataTable.ImportSheet(FileName,SheetSource, SheetDest)

FileName : The full or relative path of the Excel table from which you want to import a sheet. It can be a file system or ALM path.

SheetSource:  The name or index of the sheetin the file that you want to import. Index values begin with1

SheetDest: The name or index of the sheetin the data table that you want to replace with theSheetSource. Index values begin with 1.

导出:DataTable.ExportSheet(FileName, DTSheet)

FileName: The full file system path of the Excel table to which you want to export a sheet. 
DTSheet : The name or index of the run-time Data pane sheet that you want to export. Index values begin with1(就是你要导出的表的索引号或者表所在位 置)

取值 \ 赋值: DataTable.Value ("列名","表所在位置")

例如: LoginAccount = DataTable.Value ("LoginAccount","login")       取值

     DataTable.Value ("LoginResult","login") = result   赋值

关于循环时导入表的覆盖: 加一个判断

  rownum = Datatable.GetRowCount
If rownum = 0 Then
     DataTable.ImportSheet "D:\User\Desktop\EPM_T2_郝文浩_13章\login_DateTable\用户及登录结果.xls",1,"login"
End If

关于循环时导出表的覆盖:可将导出操作单独放入一个Action 里面

2. 关于调试

遇到错误要想到通过调试来找到问题所在。在问题位置加断点加断点,可加多个断点。

调试时可通过Data 窗口看表格数据,通过Loca Variables 窗口看变量的值。

可通过 Step O ver 一步步调试。

3.关于遇到问题

先考虑脚本流程(逻辑)是否合理,涉及到一些很细节的地方,比如要加一些判断或者是关闭一些窗口,点击一些按钮。

在遇到需要某个方法时要想到函数,用函数实现脚本中需要的操作。函数包括UFT中的和VBS中的。

通过调试找到具体问题。

0 0