How to download a pdf with Celerity when the download link is a javascript function?
link looks like this:
<a onclick="SmartScroller_GetCoords(); openPopup('CaseSearchServlet?_=gyRWOWiixsI4V5mQbu4YDfu9rnZGrO3VQ%2FFvGdRRaSOaCi7%2F9t4X1xttTQ7FK8J6TbhndUjs0vpd%0AZPSDQFaHbLZJ%2FLMVJyeZ', 'History0' , 480, 700);setTimeout('SmartScroller_Scroll()', 2000);" href="#">090416487</a>
I can't do:
browser.link(:id, 'pdf').download #=> #<IO:0x11ce78c>
Because there is no href or any other attribute to refer to, but I can get the full url of the download link. So I can do:
browser.goto("download link here")
but I get:
Celerity::Exception::Unexpect开发者_高级运维edPageException: application/pdf
Any idea how to this?
Does the link automatically prompt you to download the file? If so then you should be able to still do:
io = browser.link(:text, "090416487").download
For example I had a link like this:
<a class="plainlink" onclick="document.export_proof_activity_log.submit(); return false;" href="#Export to CSV"><ins class="icon icon_file_csv"></ins>Export to CSV</a>
And did:
io = b.link(:text, "Export to CSV").download
And the result in io was the file contents.
精彩评论