Question

Interacting with embedded element on page

  • 21 February 2022
  • 3 replies
  • 17 views

Badge +5

I am working on a bot that should be simple, but one part of it is giving me fits. The bot goes out to a public bank site like Chase.com, and downloads the Deposit Account Agreement. I have no problem with navigating to the site, or clicking the appropriate link (there are several arranged by date).

 

image 

The issue comes in actually saving the PDF. Chrome's PDF viewer uses an embedded bar at the top, so I cannot click on the Download button. The recorder only captures the entire frame:

 

image 

So this leaves me with a couple of questions. Number one, I am curious if anyone has ever dealt with downloading PDFs like this, and what your solution was for an embedded button.

 

Secondly, I tried to do this via javascript, like so:

 

var urls = document.getElementsByTagName('a');

 

for (var i = 0; i < urls.length; i++) {

  if (urls[i].innerHTML.includes('Deposit Account Agreement')) {

  if (urls[i].innerHTML.includes('11/14/2021')) {

     urls[i].download = "file.pdf";

 urls[i].dispatchEvent(new MouseEvent('click'));

    }

  }

}

 

and while this works in the Browser Console, it does not work in the Bot - no error returned in a Try/Catch block, the Javascript action just stalls until it times out. I am curious if anyone knows why it would work in the browser but not in AA.

 

Either way, Recorder or javascript, I need to find a way to get this to work consistently. Any suggestions would be greatly appreciated.

 

.


3 replies

Userlevel 3
Badge +7

Hi @Jeremiah Logan​ ,

 

Have you tried using the Capture Action to retrieve the Hyperlink, and then pass that Hyperlink into the Browser: Download File Action?

 

image 

Kind Regards,

Ashwin A.K

Userlevel 4
Badge +8

Have you tried clrt+p for print?

Badge +4

@Jeremiah Logan​ 

You could enable pdf download instead of opening it:

-Go into Chrome Control Sidebar (3 dots)

-Settings

-Under Security And Privacy - Click on "Site Settings"

- Scroll to PDF Documents

- Enable "Download PDF files instead of automatically opening them in Chrome"

imageAlso ,you could enable to ask where to save file:

image

Reply