2008年9月9日星期二

SilkTest 如何读取PDF文件

目前还没找到好的方法直接对PDF文件进行操作,但是我们可以通过将PDF文件内容copy到剪贴板,然后使用Clipboard类对内容进行处理

[ ]
[ ] // Change file location and also the browserchild name
[ ]
[-] string GetPDF(window x)
[ ] STRING sHeader
[ ] x.SetActive()
[ ] // might not need this if the popup report is already open
[ ] SYS_Execute("Start C:\filename.pdf")
[ ] sleep(1)
[ ] Desktop.TypeKeys("")
[ ] sleep(1)
[ ] Desktop.TypeKeys("")
[ ] sleep(1)
[ ] LIST OF ANYTYPE lsContent
[ ] lsContent = Clipboard.GetText()
[ ] Agent.SetOption(OPT_PLAY_MODE, "Win32")
[ ] Desktop.TypeKeys("")
[ ] Agent.SetOption(OPT_PLAY_MODE, "Normal")
[ ] sleep(1)
[ ] // change to index of title in list
[ ] sHeader = lsContent[2] // change to index of title in
list
[ ] return sHeader
[ ]
[-] testcase tOne()
[ ] print("Title of this PDF document is: " + GetPDF(BrowserChild))

这个方法只适用于需要获取文本内容,如果里面包含图片等内容仍无法处理

没有评论: