Hi all, i have code as this:
@keyword
def download_pdf_and_compare_screenshosts(self):
promise = self.browser.promise_to(
"Wait For Response",
"response => response.url().includes('api/projections/outputFile') && response.status() === 200",
"timeout=20 s")
self.builtin.sleep(2)
self.browser.click("xpath=//button[@class='mat-focus-indicator pl-0 mat-button mat-button-base mat-primary ng-star-inserted']")
res = self.browser.wait_for(promise)
self.builtin.log(res["body"])
with open("test.pdf", "wb") as fp:
fp.write(res["body"])
What this do, is it just catch the response from api call, that contains in body pdf.
Problem is, that I can’t save it. If I save it as this, PDF is blank.
If I try to do bytes(res["body"], encoding="utf-8")
it is the same, blank pdf
If I try to do b64decode(res["body"], validate=True)
I got error message about non-ascii character.
I’m kind a stuck here… … Any ideas how to resolve this problem?
part of the pdf:
%PDF-1.3
%����
2 0 obj
<</Subtype/Type1/Type/Font/BaseFont/Helvetica/Encoding/WinAnsiEncoding>>
endobj
1 0 obj
<</Subtype/Form/Filter/FlateDecode/Type/XObject/Matrix [1 0 0 1 0 0]/FormType 1/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 2 0 R>>>>/BBox[0 0 112.11 42.07]/Length 218>>stream
x���;N1Ds��!$M�M�����D��(o�J�do�~]vkV|�Ϥ�T�g���)$bS�M����U�G
��<ª�B�9N�E�<d�����P�$���FB!$��X'F��h%�J�CI��'m�.��>P\ ��Uø).�l:�9cvi��L�2
�z�4�2Hz��������1Ư+������좖ݥM��e}�'U�kY�����V��ܗ�
endstream