QTP 如何保存网页中的图像
我想知道是否可以模拟该过程:右键单击图像 ->单击弹出菜单上的“将图像另存为..”->将图像保存到本地。
我尝试了CaptureBitmap()函数,但结果只是QTP截取的屏幕截图,而不是与上述过程获得的相同图像文件。
还有其他方法吗?非常感谢。
艾伦
I would like to know if it's possible to simulate the process: Right click on an image -> Click on "Save image as.." on the popup menu -> save the image in local.
I tried CaptureBitmap() function, but the result is just a screenshot taken by QTP, not the same image file obtained as the procedure above.
Are there other ways? Many thanks in advance.
Allen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想这取决于你想做什么。如果您想比较位图,那么
CaptureBitmap
选项应该可以工作。如果您想比较图像的路径,可以使用Image("x").GetROProperty("src")
。如果您确实想保存 src 图像文件,那么不幸的是 QTP 不提供与浏览器上下文菜单交互的方法。您可以尝试使用某些第三方机制从
src
URL 下载图像(例如 wget)。编辑:我只是有另一个想法,我不在工作,所以我无法验证它是否有效,但我很确定它会有效。
首先导致上下文菜单出现,为此,您必须将重播模式更改为设备并运行
RightClick
操作。然后将字母 v 发送到浏览器,浏览器将通过使用 设备重播对象
现在,像普通 Win32 控件一样与保存对话框进行交互。
寓意:如果你足够努力,永远不要低估 QTP 能让你做的事情
I suppose it depends what you want to do. If you want to compare the bitmap then the
CaptureBitmap
options should work. If you want to compare the path to the image you can useImage("x").GetROProperty("src")
.If you really want to save the
src
image file then unfortunately QTP doesn't supply a way to interact with the browser's context menu. You can try to use some third-party mechanism to download the image from thesrc
URL (e.g. wget).Edit: I just had another thought, I'm not at work so I can't verify that it will work but I'm pretty sure it will.
First cause the context menu to appear, in order to do this you have to change the replay mode to device and run a
RightClick
operation.Then send the letter v to the browser which will select the
Save
menu item (on both IE and Firefox) by using the device replay objectNow interact with the save dialog as a usual Win32 control.
Moral: Never underestimate what QTP will let you do if you try hard enough