RPA - Selenium creates a Print dialog and stops execution

Hi There.

I am not sure if this is the right place for the question of if it should be at the Dev forum, or in the framework.

I have created a Robotframe resource that uses Selenium to go to a website, login, navigate to a button, and click it.

When the button is clicked, it brings up a print dialog, why I have a python extension to handle it.

However, at the click element command the code stops moving along and eventually I get the following time-out message:
TimeoutException: Message: Timeout loading page after 300000ms

The Dialog is triggered through a small code in JS that is called after clicking on the button. It seems to be there to handle some really old code:

function ImprimirFrame(Opcao){
var pr = (window.print) ? 1 : 0;
  if (pr){ // NS4, IE5
  parent.Frame_Principal.focus()
  parent.Frame_Principal.print() 
  }	
  else
  alert("O seu browser não suporta esta função");
};

Any ideas where to go to in order to figure why the script execution is being tied up there?

Thanks in advance
Andre

Last time I looked at print dialogues direction in test automation (which was mistake that I did have to learn), handling the dialogue required using custom library and using threads. In that time clicking on element which displays the operating system print dialogue causes Selenium to hang until dialogue is closed. I did need to put the Selenium click in a thread and in use OS specific tools to handle the print dialogue. When print dialogue was closed, in one way or another, I did need to wait for the Selenium click thread to complete.

Because printing happens in the OS side, it’s not worth of test automation (unless you are actually testing printers), exploratory testing is better option.

Thanks for the feedback Tatu.

Because I am test apps I wasn’t sure where to post it originally.What I am doing is automation for Real-state business with RFA. So it seems it would be useful to have an elegant way to handle dialogs in the framework.

I learned the hard way about the external libraries to handle the OS level dialogs. In fact I created a little class in python using pynput which I import into my robots to handle dialogs.

Now to an update on the topic. This seems to be an issue with Firefox, that is causing something to hang/go into wait mode. Just for giggles, I tried to run the script using Chrome (I stopped using chrome, because Chrome controlled by Selenium through chromedriver still does not support download a file when in headless mode). That’s the reason for the use of FIrefox.

But, this specific provider download process reaches a print dialog, and not a download, I just chrome a shot. Tomy surprise, It all worked as desired. I reach he screen to be printed, the dialog pop-in and script works fine (after a couple of extra lines to handle the differences from Firefox). My guess, there is some issue in the firefox driver somewhere that is causing the lock.

If somebody wants to check the code, I can put it on github and share the link. Keep in mind that the 3rd party site I need to access uses individual LOGIN/PWD for each doc I need to generate. I may not be able to get the full list I use in production, but I can give a single entry in the data file that the robot runs through.

PS - don’t kill me, as I am a noobie on RFA, so I am pretty sure my code is not likely up to good standards
PS2 - Sites are in Portuguese, I would not expect this to be a problem.

As alternative approach - I did one RPA project on windows which involved printing generated reports (pdf’s). I handled that by installing ghostscript binaries, just downloading the generated files into local filesystem via requests library and then calling ghostscript to sent each individual file to print spool. The whole download/print process can happen in headless browser and didn’t require any ui interaction with os level gui elements (like print dialog) …

For requests download, i got the cookies from selenium and injected those to requests session…