簡體   English   中英

量角器無需單擊鏈接即可下載圖像文件

[英]Protractor download image file without clicking on link

我正在嘗試比較兩個徽標圖像。 測試用例基本上是

  • 將圖像A下載到目錄中
  • 比較圖像A和圖像B(已存在於文件夾中)

所有指南和問題都指出了在存在執行此操作的鏈接時如何下載文件。 但是在這種情況下,我想下載僅知道其URL的圖像。

有可能嗎?

使用以下代碼段:

var a = document.createElement('a');
a.download = filename; // Set the file name.
a.href = uri; // Set the uri.
a.style.display = 'none';
document.body.appendChild(a);
a.click();
delete a;

 var a = document.createElement('a'); a.download = '58832_300x300'; a.href = 'https://i.vimeocdn.com/portrait/58832_300x300'; a.style.display = 'none'; document.body.appendChild(a); a.click(); delete a; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM