admin管理员组文章数量:1293987
I'm trying to automate uploading images in CasperJS.
The form on the site appears to be using plupload. Once a button is clicked, a file browser dialog appears where multiple images can be selected.
How can I handle this file upload form with CasperJS? Is it possible to upload multiple images all at once?
I'm trying to automate uploading images in CasperJS.
The form on the site appears to be using plupload. Once a button is clicked, a file browser dialog appears where multiple images can be selected.
How can I handle this file upload form with CasperJS? Is it possible to upload multiple images all at once?
Share Improve this question asked Sep 13, 2015 at 14:08 Willem-AartWillem-Aart 2,4604 gold badges20 silver badges29 bronze badges 01 Answer
Reset to default 11Even custom file upload widgets use an <input type="file" ...>
element underneath their UI. That is necessary in order to get access to files on the client machine.
You can bypass the widget UI by directly setting the file that needs to be uploaded. Since CasperJS is built on top of PhantomJS, you can use all PhantomJS functions including page.uploadFile(selector, filename)
. In your case that would look something like this:
casper.page.uploadFile("#uploaders input[type='file']", myfilename);
Note that it is also possible to use all casper.fill*()
functions provided you know the file input element name beforehand and the file input field is inside of a form element.
本文标签: javascriptJS file upload with PhantomJSCasperJSStack Overflow
版权声明:本文标题:javascript - JS file upload with PhantomJSCasperJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741591770a2387169.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论