51Testing软件测试论坛

标题: QTP中如何使用外部的excel数据? [打印本页]

作者: maplee    时间: 2013-7-2 17:20
标题: QTP中如何使用外部的excel数据?
新手求助。。。
有一个webedit输入框,在输入框中输入序列号后,会提示相应的信息。
要输入的序列号以及相应的提示信息,是存储在一个外部的excel文件中的,
例如:A列存储序列号,B列存储提示信息,一共100行(也就是100个不同的序列号和提示信息)
要在QTP中从1~100依次输入序列号,并和B列的提示信息进行校验,该怎么实现啊?
作者: 赵佳乐SMILE    时间: 2013-7-3 11:28
得写代码
看你这个应该不难实现

http://user.qzone.qq.com/3051324 ... &pos=1361440904
作者: joykao    时间: 2013-7-3 11:29
你需要读写excel中的数据,A 列是测试输入数据,B列是检查数据当做检查点

具体的你可以去看看Excel的读写

比如datatable.importsheet 或者使用EOM
作者: maplee    时间: 2013-7-3 14:25
嗯,搞定了,谢谢楼上两位。
作者: 赵佳乐SMILE    时间: 2013-7-3 15:01
回复 4# maplee


    这么速度 厉害啊
作者: maplee    时间: 2013-7-4 11:42
本帖最后由 maplee 于 2013-7-4 11:46 编辑
回复  maplee


    这么速度 厉害啊
赵佳乐SMILE 发表于 2013-7-3 15:01


呵呵,我是这么写的,求指正~

Dim excelApp
Set excelApp =CreateObject("excel.application")
        excelApp.Visible = true
        excelApp.Workbooks.Open "D:\KEN_ALL.CSV"

Dim cRow, RowCount
RowCount = excelApp.ActiveSheet.UsedRange.Rows.Count
Dim oSheet, zipCode, City, District_1, District_2, District
Dim City_Check, District_Check
Set oSheet =excelApp.Sheets.Item(1)


For cRow = 0 To RowCount -1
        zipCode = oSheet.Cells(cRow+1, 3)
        City = trim(oSheet.Cells(cRow+1,7))
        District_1 = Trim(oSheet.Cells(cRow+1,8))
        District_2 = Trim(oSheet.Cells(cRow+1,9))
        District = Trim((District_1&" "&District_2))

       dataInput
Next
作者: 赵佳乐SMILE    时间: 2013-7-4 13:28
回复 6# maplee


    简洁 比我规范多了 哈哈
作者: 黑羽祭    时间: 2013-7-4 14:34
不错啊~
作者: maplee    时间: 2013-7-4 16:52
谢谢楼上两位夸奖,我是新手,学习中遇到很多麻烦,
经过二位一表扬,信心增强了很多
作者: 450174661    时间: 2013-7-11 13:23
maplee真犀利,学习了




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2