How to click on download of pdf and save inside browser windw in robot framrwork

Hi,
Using robot framework 4.1.3 and python and chrome browser.
I am not able to click download icon and save pdf which is inside of browser. Looks like pdf is inside the iFrame.

Can you please suggest?

Hi @bk-user,

That button is part of the pdf viewer not html, so libraries like SeleniumLibrary and Browser won’t be able to interact with it.

Depending on your OS, you can use Libraries like ImageHorizon, SikuliLibrary, AutoItLibrary or FlauiLibrary, basically for this you are going to have to treat it like a desktop app not a webpage.

Dave.

Thanks @damies13 , Which library works on all platform, I wanted to my script on windows and linux platform. Could you please provide any reference link which useful to install and implement code for the download pdf.

AutoIt only works for windows and I tried SikuliLibrary on windows but getting error referenced here- Getting permission error while importing Library -SikuliLibrary

I also installed -pip install robotframework-imagehorizonlibrary

But not able to import - Library ImageHorizonlibrary
Getting same error like SikuliLibrary

Then I wanted to try -

  1. Press Combination Key.CTRL Key.S
    or
  2. Click Image ImagePathOfPDFSaveIcon

Hi @bk-user,

SikuliLibrary and imagehorizonlibrary are both supposed to be cross platform

  • SikuliLibrary is java based so in theory should work, but I’ve had issues with getting it to work in my github build tests, particularly on Linux
  • imagehorizonlibrary I was able to get working on all three platforms (windows, linux and MacOS) but I found several bugs, which i’ve submitted fixes for, I’m hoping my pull requests for imagehorizonlibrary get accepted, the most important (to-me) fix was the one that dealt with screen scaling. This could explain if you are having issues with Click Image ImagePathOfPDFSaveIcon

Another thing you could try is using Selenium libraries Press Keys, though i’m not sure if SeleniumLibrary will pass that keypress to the pdf plugin and it still doesn’t deal with the save dialogue afterwards.

Press Keys	//iframe[@id="vQzPed"]	CTRL+s

Most of the topics on this forum where people have had success has been AutoIT library, but yes that is windows only.

Sorry I can’t offer a better solution at the moment, if your not on windows SikuliLibrary and imagehorizonlibrary are your best options.

I have several desktop GUI apps I want to do regression testing on all three platforms and don’t have a good solution either, I’m looking at creating a library that uses the os level accessibility API’s but it’s not anywhere near usable yet which is why I didn’t suggest it (robotframework-accessibility)

Dave.

Thanks for explanation @damies13 . In my case, after installing Sikuli or ImageHorizon, I am not able to add Library or import Library.

These 2 variations worked for me:

Import Library	ImageHorizonLibrary	reference_folder=images
Library	ImageHorizonLibrary	reference_folder=${CURDIR}/Images 	confidence=0.9

I don’t recognise the editor your using, it could be a problem with your editor not recognising ImageHorizonLibrary being installed or it’s using a different python environment from the one where you installed ImageHorizonLibrary?

I’m a bit old school and don’t use code completion or fancy editors, I just use a basic text editor so I’m not sure I can help with this.

Maybe change the topic title to “xyz editor not recognising robot framework libraries” and then you might get the answer you need.

Dave.

Thanks @damies13
Library ImageHorizonLibrary reference_folder=images ======> This way worked for me. I will try with image click now

1 Like

@damies13
I tried ImageHorizonLibrary with Click Image method but somehow its not working.

I tried to click savepdfIcon on pdf opened in browser and click Save button windows save dialog. Looks like click image is not working

If you remember what I mentioned about screen scaling with ImageHorizonLibrary?

  • If you are using MacOS Click Image probably won’t work (it doesn’t for me) It looks like you aren’t from the screen shot
  • if you are using Windows/Linux you need to make sure your screen scaling is set to 100% e.g. Windows settings or Ubuntu settings

If your screen scaling is anything other than 100% then Click Image and many other keywords won’t work until this PR is accepted

You could work around it by using Locate to get the co-ordinates, then scaling the values (i.e. for 200% screen scaling, divide the x and y values by 2) then use Click with the adjusted co-ordinates

Alternatively, when that save screen comes up, press ALT on the keyboard and if an underscore comes up on the letters of the word Save/Cancel on the buttons, if so, use press keys again with ALT+

Dave.

@damies13 Thanks , its very nice and detailed explanation
Tried after setting screen scaling to 100% on windows and saved image in same resolution but Click Image imagename not working.

Locate also not returning co-ordinates

Tried after pressing ALT or ALT+ also