How do I download multiple files at once from a browser without combining them into single file? I found all kinds of multiple file uploaders, but downloaders are missing. There is only JUpload, but it's old and became buggy recently. I believe both Java and Flash can do this: select a folder at client's HD and download everything there.
The only solution I can think about is a performing multiple AJAX calls to each file separately. All this calls may be invoked by single click of user. This will look OK in Chrome because it does not ask (by default) where to put the downloaded file and put all files into pre-configured download directory.
I think that in Firefox the user will see pop-up that asks what to do with file (download or open) for each file separately.
MSIE will ask where to save each file.
Bottom line: this solution will look good in Chrome only. Other browsers should be configured properly.
Related
I am using Selenium and I need to upload an image to instagram. But at the time the windows file selector opens I could not get it to search for the image and upload it automatically
Up to this point my application opens well, when it goes to the point of selecting the file it does not do it automatically
I tried using the following codes without success
driver.findElement(By.className(name)).send_keys('C:\\path-to-file\\file.jpg')
But it gives me back the value of the second photo, that is, it generates a file selector from the main folder and not the one that I pass through as a parameter
I am using the following versions:
Java: 8
Selenium: 3.14
ChromeDriver: 76
Normal browsers don't allow JavaScript any access to the local disk. This is basic security. Imagine what would happen if you visit some site and it reads your local password file or any other important data without asking you.
If you want to upload files, take some standalone application or write a small utility that will do that. For instance, try instapy, you can find it pypi.org or on github. It is a matter of taste, the other can prefer other tools. Just try several tools and see which fits your need better.
The window opened for file explorer is not part of the browser and therefore it can not be interacted with via selenium. The solution to this is a software called AutoIt. Use the following link for a guide on how to use AutoIt for file uploads : Link
We're currently using a web automation tool that makes us download a localexecute.jnlp file everytime before running the testcase. Then it says downloading application and that continues for about 3-4 minutes.
Is there a way to bypass this, because it is very time consuming.
Thanks.
You can try just saving the JNLP file somewhere (e.g., right click on the link in the browser and save it) and then opening the saved file directly.
This assumes that the JNLP file doesn't change each time, which it may well do (for example, to add some secure token). In that case, it won't work.
You also have to keep in mind that since you are testing, you might be invalidating your tests by not loading the latest JNLP file each time.
This is a problem I've been struggling with for a few weeks now, but can't seem to find a viable solution. In a nut shell, my program goes to a website and downloads a handful of files. When it goes to download a file, FireFox always displays the popup asking where I want to save it to. In an attempt to get rid of this popup, I created a profile preference.
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/zip,application/vnd.ms-excel");
This preference works great with the one zip file I need to download, but it's completely ignored for the other 3 Microsoft CSV files that I need. I have tried every applicable mime type I can think of and none of them work. I ran my file through an online program that is supposed to tell you what mime type the file is, and it proclaimed the file I tested was a application/vnd.ms-excel. Unfortunately though, I have never been able to get this type to work. I have tried various different ways of setting up the profile, such as:
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/zip" + "application/vnd.ms-excel");
And even just using application/vnd.ms-excel without the zip type in front of it, and still no dice. Is there another way to set this up to where I don't have that window popup each time I try and download these files? Better yet, is there something wrong with my code that would allow the zip file to work, but not the Microsoft csv?
Here is a set of CSV-specific mime-types that worked for other users here on SO:
profile.setPreference('browser.helperApps.neverAsk.saveToDisk', "text/plain, application/vnd.ms-excel, text/csv, application/csv, text/comma-separated-values, application/download, application/octet-stream, binary/octet-stream, application/binary, application/x-unknown")
I'm pretty sure that the application/x-unknown is the one that would work for you since this is what Firefox itself determines as your file's mime-type (worked for me).
You may also do the following:
download this specific file manually with Firefox
when the Save File popup would be opened, check the "do this automatically for files like this from now on" checkbox and save the file
now, go to Help -> Troubleshooting Information
find the profile directory and save the path to it
in your Selenium code, start Firefox with the FirefoxProfile pointing to this existing profile, see more about how to do it here
I have an internal app that creates a set of files, they are then zipped up with php and presented to the user with download headers. The user then downloads the zip file, must unzip the folder and copy the files over to a specific directory on their computer.
I need some direction on how I can allow the user to preset this folder so when they click a download button, all of the files in the set will just download to that specific folder on their hard drive.
I realize that besides having the user set their browser's download directory, this isn't normally possible. But I know that it can be done with a java applet or maybe flash. Can someone point me in the right direction on how to create a small app like this. I would assume the user would have to download the app and allow it access the first time they used the site, then after that, I would like them to be able to just click a button and download the files.
I am quite certain that this can be done, as I have seen it before. But I can no longer find the site that did it. Even if the app at least popped up a file browser window to select the folder to download to that had the preferred folder pre-selected, that would be good enough.
-On your server create a file with a list of files to be downloaded as a relative path to it.
-Retrieve this list as an array/list of strings
-Create a ThreadPoolExecutor and submit a Runnable for each of the files (strings) in the list. The Runnable should work on SERVER_URL + RELATIVE_LINK
That should get you started...
Oh, btw, your applet needs to be signed in order to access the disk drive.
If it is an option, create a runnable jar and let the user download it.
I'm trying to find something that will let users upload multiple files to a website. The requirements are that it let them easily select multiple files (preferably with something like check boxes) and that it displays a preview of the images they select.
I'd prefer to only use Javascript or Flash if possible, but Java is also an option (this needs to work on platforms where Silverlight isn't available).
So far all I've been able to find are things that use the native file selector (which doesn't show previews on Windows, and makes it unclear that you can select multiple by holding ctrl).
I'm not sure if the preview requirement is even possible, but it's the most important.
This is a firefox solution:
It uses the FileReader javascript object to load, display and upload images.
http://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
It still doesnt show previews in the FileSelection dialog but at least allows you to preview the images before uploading.
And here is a ready made java applet solution:
http://jumploader.com/doc_overview.html
To upload multiple files I use RichFaces rich:fileUpload component.
Concerning the preview, I've got the similar problem and the best I found after couple of days of googling is following.
Alfresco has the same problem and resolved it with :
An open office which runs in server mode (socket) and all the office documents are sent by alfresco to open office in order to convert them in PDF
Those PDF are converted to .swf viewer thanks to SWFTOOLS
This .swf is integrated in the HTML
For images, it uses ImageMagick to create small version of the file I suppose
Personnaly, I will try to implement it this way :
Converting office documents to PDF thanks to open office in socket mode
Transform the first page of the PDF into a PNG thanks to JPedal library
Diplay that PNG to the end user
For images I would perhaps use ImageMagick too ... but for now, I'm using Seam Image.scaleToFit API
I am assuming 2 things here:
1) Some kind of client/enduser will be doing the file upload
2) You get some kind of say on what the client installs on their computer to help make this happen.
If this is the case, my first suggestion would be:
Give them FTP or SFTP client software to upload files. The php page you make can have a link to Filezilla, along with instructions on how to use it. ftp and sftp are THE protocols to use for transferring files. HTTP is just not designed(well) for it, nor are browsers.
Once the user has the (S)FTP client software installed, you can give them URL's to upload files to that are specific to their user account, and you can have a backend script process and load/move files that they upload. It's pretty easy to create a local temporary directory using a server side script, have the client upload files via ftp, then go back to the web browser and click a button that says "Done uploading, please process my stuff".
The browser can even give back confirmations on everything that gets uploaded/processed.