How to write a script that interacts with web browser and print content as PDF? - scripting

I'm looking to write an automated script that
Opens up a browser instance with a specific URL
Print the page as PDF output to a pre-defined location and document name
Simulate a click event on the web page that goes to the next report
Repeat 2 and 3 for a fixed number of times.
I'm not sure how to start doing this. Thought of using Javascript, but it won't be able to automate the printing process.
There is no control of the server, therefore I cannot use a query to get the collection of those reports.
The reason for the script is that there are many such reports, and the server can be very slow at times, it would be better to have them locally.
UPDATE: Forgot to mention that log in is required for the server.

I think scripting an off-the-shelf browser is very much the Hard Way to solve your problem. If you can at all predict the URLs for the individual report, use a command-line tool such as wget or curl to download them, and then look at this community wiki for rendering the downloaded HTML as PDF.
Or do you even need to go to PDF? If all you're interested in is having the reports available locally, why not keep them as HTML and view them in a browser (with a file: URL) rather than a PDF viewer?

Related

Test Automation - Katalon - upload file when it's scanned for viruses

I was trying to upload a file from my local to the web page. I’m able to select the file using the Robot class, but I’m stuck on a part. When it uploads the file, I see a message in UI that the file is in “scanning for viruses”. But, it doesn’t complete. And I can’t move forward because the file upload is not complete as it’s still being scanned for viruses. (Screenshot attached)
However, in my application, when I open a session manually and upload a file manually, it’s being scanned for say max 2-3 seconds and after that, I see the upload is complete. Only, when the session is opened by Katalon, I’m not able to complete the upload as it gets stuck on scanning.
Can you please help me figure out why would it behave differently when done from an automated script as compared to a manual execution? Is it something related to browser settings when Katalon opens it? And how to handle this part in an automated script?
Please have a look at this. Looking forward to a reply.
enter image description here

SSRS - "Print We'll create a printer-friendly PDF version of your report."

All Reports when click the print button open a PDF option with
but I want to print straight to the print.
I've tried to change a few configurations on SSRS but does not work, my research so far:
https://learn.microsoft.com/en-us/sql/reporting-services/report-server/enable-and-disable-client-side-printing-for-reporting-services?view=sql-server-2017
This thread and its linked pages answers the challenge completely
https://social.msdn.microsoft.com/Forums/en-US/5a631f79-a116-49b7-8f55-826c050a38ce/printing-from-ssrs-2016-dirrectly-to-printer-without-pdf-reader?forum=sqlreportingservices
http://printssrsreport.blogspot.com/
https://neelb.wordpress.com/2018/09/26/ssrs-enable-disable-client-side-printing/
Microsoft has intentionally limited direct printing without intervention for good reason.
In all scenarios printing reports is bad -- data is out of date immediately, paper wastage, print server administration (and automation if you go down that route)
Reading through the noise - Chrome browser offers a marginally better experience because it has an inbuilt PDF viewer - so the user experience would marginally better than having to open a separate application to view the PDF - from Chrome the facility to print the PDF is trivial
To achieve this, you need to do some programing using c#. I am not sure that you have this option available for you or not. In case, if you would like to see how it that code looks like refer below link. This might help. Even you can setup default printer and pass parameters like username, date range etc. I was looking for a way to set default printer using code and found this link.
ReportExecutionService

Somehow send command line commands on windows externally and get back the response

Problem: Need to convert local html (with local images etc) to pdf from an AIX box running Universe 11.2.5 with System Builder
Current solution: FTP over html file to a Windows server which converts in batches and sends the e-mail to the destination
Proposed Solution: Do everything on the AIX box, from converting html to pdf and sending the e-mail.
Current problem: Unable to find a way to convert local html to PDF on the AIX box. I have been trying many different ways from trying to install Python3, but to no avail.
The only really difficult part of the process is getting the HTML to render into a format will properly display your html into pages that are suitable for printing. There is a fair amount of magic that goes on between HTTP:GET and clicking print on a browser window that needs to be accounted for.
I was trying accomplish something similar many moons ago on AIX but kind of ran into a skill level/time wall because I was going to have essentially create a headless browser to render the html. It looks like there are now some utilities that you might be able to leverage. I found this recent updated article on Super User that actually got me somewhat excited, especially since I don't use AIX anymore so precompiled binaries and well understood and easily attainable dependencies are something I can actually have in my life.
https://superuser.com/questions/280552/how-can-i-render-a-website-as-an-image-from-the-shell
Good Luck.
There seems to be several questions rolled into this one item.
Converting HTML to PDF, while that is just a data manipulation that you could do in basic, writing such code would be a large task. The option you use sending it to another system is valid, but put more points of failure into the system. I would think you could find code to do it on the AIX box.
Rocket plans on getting the MV Python to work on AIX, this will make the converting of html to PDF much easier since there are a lot of open source modules.
As for my suggestion of using sockets, that would be if you intend to send it to a service that will take the htms, and return the pdf document.
i.e. Is there a web service for converting HTML to PDF?
Once you have the pdf document, you can either store it in a UniVerse type-19 file, or do the base64 encoding and store it in UniVerse hash file.
Hope this helps,
Mike

How can I extract the title of a pdf when downloading them?

I deal with pdfs a lot but when I try to download them it usually doesn't contain the actual title of the pdf/paper so I'll have to rename it most of the times, which I find is annoying.
In many cases URL doesn't have the title of the pdf, so I guess this has to be extracted by processing the content of the pdf. And it needs to be done on the client side, i.e., for e.g., as a browser plugin?
Is there a way that I can get the title when I'm downloading pdfs over the web via scripting or someting?
That most likely won't work and here is why.
You would have to write some incredibly dynamic code to fetch some sort of title for the PDF. You would have to have code that would scan a website, somehow pick out a title, then fire off a request to code running on your computer to change the name.
It would be somewhat inconvenient because you would always have to have the script run on your computer (likely always having terminal open).
Your code would be highly prone to error. If your website script messed up, you could accidentally name the PDF incorrectly and then not be able to find it based on how inaccurate the name is.
For now, I would suggest dealing with the pain of editing the PDF name manually.

Loadrunner file upload

I have Google'd this subject a lot over the past few days, but I cannot find a best practice solution. My question is basically how do I script in LR a fileupload? My app consists of a browse button, a pop up that lets me locate the file and it closes after I have located the file. Finally the app has a upload button to upload the file.
My script is recorded using URL mode and I guess I need to create some kind of custom request? URL mode creates somewhat complex scripts and placing custom requests inside these script is challenging.
BTW: I have not tried to record and play back the file upload process described yet, and using URL mode might just solve it without further customization? Or did someone actually made file upload using LR and URL mode work? A small example would be greatly appreciated!
Different applications will go about uploading a file from a client to a server in different ways. Your best bet is to record your application doing the upload and taking a look at what LoadRunner records.
Mark the point before and after the upload as you record by creating a transaction so you can easily find the spot in your code where the upload actually happens.