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
I suppose it depends what you want to do. If you want to compare the bitmap then the
CaptureBitmapoptions 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
srcimage 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 thesrcURL (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
RightClickoperation.Then send the letter v to the browser which will select the
Savemenu 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