Download JS file using PhantomJS / CasperJS

I am trying to automate the loading of images in CasperJS.

The form on the site seems to be using plupload. After clicking the button, a file browser dialog opens, in which you can select multiple images.

How can I handle this file upload form using CasperJS? Can I upload multiple images at once?

+4
source share
1 answer

Even file upload user widgets use an element <input type="file" ...>under their user interface. This is necessary to access files on the client machine.

You can bypass the widget interface by directly setting the file you want to download. Since CasperJS is built on top of PhantomJS, you can use all the features of PhantomJS, including page.uploadFile(selector, filename). In your case, it will look something like this:

casper.page.uploadFile("#uploaders input[type='file']", myfilename);

Please note that it is also possible to use everything casper.fill*()provided that you know the name of the file input element in advance and the file input field inside the form element.

+10
source

Source: https://habr.com/ru/post/1607162/


All Articles