Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Save a blob PDF file with Selenium

I'm trying to download a blob PDF file with Selenium. The source page doesn't contain a link to this PDF, the link is created "on the fly", so I make some manipulations on the site, get "blob:https://.." link and run the JS below to get this file:

function blobToString(b) {
    var u, x;
    u = URL.createObjectURL(b);
    x = new XMLHttpRequest();
    x.open('GET', u, false);
    x.send();
    URL.revokeObjectURL(u);
    return x.responseText;
}

var xhr = new XMLHttpRequest();
xhr.open('GET', 'blob:https://...........', true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
  if (this.status == 200) {
    var myBlob = this.response;
 
document.querySelector("body").setAttribute("test",blobToString(myBlob));

  }
};
xhr.send();

So, for now I'm able to get this blob PDF to Selenium by saving it's content to some element's attribute and getting it to the Selenium after that.

The problem is that PDF doesn't open as a normal file, some of it's content is coded with strange symbols:

Downloaded with Selenium: �0 ��W�Ǻ�M�D�J��B�B� Q��P �oﵜ��w�,��� Y�4���E\4~�310�4���bk� �� ɔ�4}p� �\uq���zwcN��i��i��c�V���տ � �

Downloaded manually: Â0^T<85>áWùǺ¤MÒDçJÅÅBáBç^NQ<94>¦P^U±oïµ<9c>åÀwà,ô<94>ò¥¹^\Y¨4¡òÆE\4~Ï310«4<82>ÝØbk¥^CÁÔ^QÉ<94>ç4}pÖ^D<8f>\uq£<90>ôzwcNüËiÌ÷iÝÉc³Vô±§Õ¿^_^\³^^×

So I need to perform some kind of encoding/decoding to make it work. Please, help with this.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!