UFT基础_参数化之datatable详解

来源:互联网 发布:linux给文件赋权限 编辑:程序博客网 时间:2024/06/05 11:03

UFT 14 参考手册,及理解基本的VBScript 语法,
https://admhelp.microfocus.com/uft/en/latest/UFT_Help/Subsystems/FunctionReference/Subsystems/OMRHelp/OMRHelp.htm#OV_Supp_Util/Overview.htm%3FTocPath%3DObject%2520Model%2520Reference%2520for%2520GUI%2520Testing%7C_____0

'first这列输入1  1 3 执行会执行3次,只有删除第三行才会执行两次或着设置只执行一次,方法:文件->设置->运行->数据表达式->只运行一次迭代'msgbox datatable("first","Global")''也会执行三次'msgbox "aa"'action1使用全局中的数据'msgbox datatable("first",dtGlobalSheet)''action1中使用本地中的数据'msgbox datatable("bb",dtLocalSheet)''action1中使用action2中的数据'msgbox datatable("bb","Action2")''globle中的数据'msgbox datatable(1,1)'action1中的数据'msgbox datatable(1,2)'action2中的数据'msgbox datatable(1,3)'action2中的数据第三列(C列)中的数据'索引方法'msgbox datatable(3,3)'命明方法'msgbox datatable("C","Action2")'统计globalsheet中的行数'msgbox datatable.GetRowCount' 从一列中循环取值'For i = 1 To datatable.GetRowCount Step 1'   msgbox datatable("first",dtGlobalSheet)'使当前行下移一行SetNextRow方法'   datatable.SetNextRow'   datatable.SetCurrentRow(i+1)'Next''赋值'datatable.value("first","Global")="test"'datatable.Value(1,2)= "test_02"''导出当前Action中的数据到Action1.xls表中''datatable.Export("D:\UFT\uft_11\Action1.xls")'导入Action1.xls中数据到当前Action中datatable.Import("D:\UFT\uft_11\Action1.xls")'导出Gloabal,Action1,Action2中数据到data.xls中datatable.ExportSheet "d:\data.xls","Global"datatable.ExportSheet "d:\data.xls","Action1"datatable.ExportSheet "d:\data.xls","Action2"![Global中的数据](http://img.blog.csdn.net/20171116194753352?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdGpqaW5ncGFu/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
'参数化登录功能Wpfwindow("HPE MyFlight Sample Applicatio").WpfEdit("agentName").Set datatable("agentname",dtGlobalSheet)Wpfwindow("HPE MyFlight Sample Applicatio").WpfEdit("password").Set datatable("password",dtGlobalSheet)Wpfwindow("HPE MyFlight Sample Applicatio").WpfButton("OK").Click
'fromcity验证参数化Set fromcity= Wpfwindow("HPE MyFlight Sample Applicatio").WpfComboBox("fromCity")For i = 0 To fromcity.GetItemsCount -1    If fromcity.Getitem(i)=datatable("fromcity",dtGlobalSheet) Then'    print i&" is right"   Reporter.ReportEvent 0 ,i,"is right"else'    print i&" is wrong"   Reporter.ReportEvent 1,i,"is wrong "End Ifdatatable.SetNextRowNext