简单说明:脚本实现了数据和业务相分离,即数据录入和脚本开发可以由不同的人去完成。
假设数据Excel表已完成,之后可以分三步走
1.按需求将所需的对象保存到对象库中
2.按需求步骤和自己的逻辑完成代码录入,代码如下
3.在运行脚本之前,需要在UFT里面的文件——设置——运行——只运行一次迭代。
DataTable.Import("C:\Users\LM\Desktop\ShopTask.xlsx")
For i = 1 To 2 Step 1CurrentRow = DataTable.GetSheet ( "Global" ).GetCurrentRow
DataTable.GetSheet ( "Global" ).SetCurrentRow (i )
With Browser ( "会员登录" ).Page ( "会员登录" )
.WebEdit ( "j_username1" ). Set DataTable ( "用户名", "Global" )
.WebEdit ( "j_password" ). Set DataTable ( "密码", "Global" )
.WebButton ( "登录" ).Click
End With
Browser ( "会员登录" ).Page ( "完善信息 | 数字本草" ).Link ( "卖家中心" ).Click
With Browser ( "会员登录" ).Page ( "数字本草" )
.Link ( "基础信息" ).Click
.WebEdit ( "name" ). Set DataTable ( "店铺名称", "Global" )
.WebEdit ( "description" ). Set DataTable ( "店铺简介", "Global" )
.WebEdit ( "contactName1" ). Set DataTable ( "联系人1", "Global" )
.WebEdit ( "contactPhone1" ). Set DataTable ( "联系人1电话", "Global" )
.WebEdit ( "contactName2" ). Set DataTable ( "联系人2", "Global" )
.WebEdit ( "contactPhone2" ). Set DataTable ( "联系人2电话", "Global" )
.WebEdit ( "contactName3" ). Set DataTable ( "联系人3", "Global" )
.WebEdit ( "contactPhone3" ). Set DataTable ( "联系人3电话", "Global" )
.WebEdit ( "telephone" ). Set DataTable ( "座机号", "Global" )
.WebEdit ( "fax" ). Set DataTable ( "传真", "Global" )
.WebEdit ( "qq" ). Set DataTable ( "QQ", "Global" )
.WebList ( "countryIso" ). Select DataTable ( "国家", "Global" )
.WebList ( "regionIso" ). Select DataTable ( "省份", "Global" )
.WebList ( "cityCode" ). Select DataTable ( "市级", "Global" )
.WebList ( "cityDistrictCode" ). Select DataTable ( "地区", "Global" )
.WebEdit ( "street" ). Set DataTable ( "街道", "Global" )
.WebButton ( "提交" ).Click
End With
Browser ( "数字本草" ).Page ( "数字本草" ).Link ( "[退出]" ).Click
Next