Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

download file stored Location and handling Download Popup using selenium webdriver with JAVA

Please suggest an idea with following points implementations

1.how to handle the Download popup in IE with Selenium Webdriver with JAVA? want to save that Xml file

2.how to store that xml file in different location by using JAVA?

Note: we will pass 'n' number of Inputs and each input have an xml file , required all the xml file download and save in different location

like image 480
Prabu Avatar asked Dec 25 '22 14:12

Prabu


1 Answers

I would recommend you NOT to automate file download using selenium. It's a trap you don't want to fall for. File download works differently in different browsers. People will recommend using AutoIT, but it only works for windows, so cross platform testing is not possible. Since you use Java bindings, you could use the Robot class, to move your mouse pointer to a certain location on the window and send a native click. In my experience this solution is really flaky. You don't know the exact location where you must click and with Robot you are blindly clicking on things. To add to this, when you are running tests on remote machine using selenium grid, things get even more difficult.

So how do you download the file? Just get the underlying link to download the file available in your DOM and fire a GET request. Download the content if you want to validate the file. If you don't want to validate the content, just response code is fine. Here is a fantastic blog with Java examples on how to download files in the background using http requests and detailed explanation on why downloading files using selenium is a bad idea.

like image 129
nilesh Avatar answered Apr 05 '23 23:04

nilesh