0

I tried to write a SeleniumIde Plugin that allows me to write some values in a .csv file. So, I created this js code to create a temp blob file that I can save:

var blob = new Blob([""], {type: 'text/csv'});
if(window.navigator.msSaveOrOpenBlob) 
{
  window.navigator.msSaveBlob(blob, filename);
}
else
{
  var elem = window.document.createElement('a');
  elem.href = window.URL.createObjectURL(blob);
  elem.download = "test.txt";        
  document.body.appendChild(elem)
  elem.click();        
  document.body.removeChild(elem);
}

In fiddler this works, but selenium ide is not a "real" website so window.URL.createObjectURL creates a url like this null/myBlobHash. Has anyone tried to write a .csv file or other files from selenium ide?

Thanks, Christoph

cdomination
  • 605
  • 1
  • 7
  • 25
cpiock
  • 1,275
  • 2
  • 17
  • 44

1 Answers1

0

Idk maybe it will not help you. But I was facing a pretty similar thing. But I was not going to create Selenium IDE plugin. I just used runScript Selenium command the way like:

runScript

var textFile = null,   
makeTextFile = function (text) {var data = new Blob([text], {type:'text/plain'});           
  if (textFile !== null) {       
    window.URL.revokeObjectURL(textFile);     
  }      
  textFile = window.URL.createObjectURL(data);        
  return textFile;   
}; 
result=makeTextFile('lol'); 
var elem = window.document.createElement('a'); 
elem.href = window.result; 
elem.innerHTML = 'Test_text_link'; 
elem.download = "test.txt"; 
elem.setAttribute('id','test_download'); 
window.document.body.appendChild(elem);

After that I've clicked link by standart Selenium click command. And it's working.

So here is my suggestion: If you want to create such plugin it is good idea to take a look at how runScript is working. Or maybe just use it.

Good luck

Antesser
  • 669
  • 4
  • 5