将含硒的文件上传到Dropzone.js [英] Upload file with selenium ide to the Dropzone.js
本文介绍了将含硒的文件上传到Dropzone.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建硒测试,但现在遇到了问题。
我无法编写从本地磁盘上载文件的测试。
I'm creating selenium ide tests and now I have problem. I can't write test for uploading a file from local disk.
我的放置区如下:
http://www.dropzonejs.com/examples/simple.html
有人可以帮我吗?
推荐答案
我遇到了同样的问题,在这里找到了答案:
如何与Dropzone进行交互使用硒
I ran into the same issue and I found the answer here: How to interact with Dropzone using selenium
我使用了其中的大部分,但是我必须创建自己的方法才能正确转换为base64。
I used most of this but I had to create my own method to convert to base64 properly.
public static String convertFileToBase64String(String fileName) throws IOException {
File file = new File(fileName);
int length = (int) file.length();
BufferedInputStream reader = new BufferedInputStream(new FileInputStream(file));
byte[] bytes = new byte[length];
reader.read(bytes, 0, length);
reader.close();
String encodedFile = Base64.getEncoder().encodeToString(bytes);
return encodedFile;
}
希望这会有所帮助!
这篇关于将含硒的文件上传到Dropzone.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文