Download file without auto save on browser

Hi guys, for those who uses RPA express, how can you manage file download without auto saving when clicking download button?

The reason for this is, I need to save the file with my own formatted name and not the auto generated filename.

Thank you in advance

@rolando_evaris,

it depends on your browser settings - you can enable the save as dialog for each download.

There is a possibility to right-click a link and select the “Save object as” option.

And finally, you can go to the Downloads folder or Browser Downloads (CTRL + J) and rename your file

Hi @azinchuk, as always I appreciate your support. :slight_smile: In my case, the donwload link has no absolute link in it. Right Click and save as object is not possible because of JS mechanism has on that link.

My solution:
What I did is on every process that opens a portable browser (Firefox) the robot goes to settings page (about:preferences) and check “Always ask me where to save file”. After this, it continues on normal robot process.

hope this help to others. :slight_smile:

4 Likes

Brilliant!

Hi,
Had the same issue.

I have used above actions in script this solves the issue.

Ctrl +t                //to open a new tab
type "about:preferences"   in address bar  &  press enter
Now click on "Always ask where to save file radio".
type ctrl+w to close the opened tab.

Thanks

1 Like

Hi,

Could you guys suggest any work around for Chrome. Most of my automatons are chrome based.

Thanks,
Narendra

Is there a solution by entering code for the Chrome browser to set the preference on the portable Chrome browser? I tried to select a profile but for some reason I could not log into the site after that.

@narendra_purTG @matt_brownROPH

To always open Save As dialog in Chrome, export your recording to a bot task and add this capability:

<capability name="chromeOptions">
                                         <script return="chromeArgs"><![CDATA[
                                                import java.util.Hashtable;
                                                import org.openqa.selenium.remote.DesiredCapabilities;
                                                import org.openqa.selenium.chrome.ChromeOptions;
                                                ChromeOptions options = new ChromeOptions();
                                                options.addArguments("--disable-notifications");
                                                Map<String, Object> chromePrefs = new Hashtable<String, Object>();
                                                chromePrefs.put("profile.default_content_settings.popups", 0);
                                                chromePrefs.put("download.prompt_for_download", true);
                                                options.setExperimentalOption("prefs", chromePrefs);
                                                options.addArguments("disable-infobars");
                                                chromeArgs = options;
                                         ]]></script>
                                  </capability>

Additionally:

  • Use chromePrefs.put("download.default_directory", download/file/path); to set the default download location.
  • Use options.addArguments("user-data-dir=/path/to/your/custom/profile"); if you need Chrome to open your default profile instead of creating a new one.

Thank you so much! Very helpful!

1 Like

im trying to use this in my BP, but I keep getting an error:

Step name ‘****’ has failed. Reason: '[urn:uuid:144A1B77988AAA8A4A1534529246242153] robotics-flow executePlugin exception: [nodeId=005f4537afae7cfe20fabb65e3b38762http://127.0.0.1:5002] org.webharvest.exception.ScriptException: Config line 59: script block org.openqa.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions Command duration or timeout: 0 milliseconds Build info: version: ‘8.5.1’, revision: ‘87eae3e04f’, time: ‘2018-03-14T11:03:21.319Z’

Any help would be appreciated

@shc9170 could you please share your bot task and the error log to investigate? Thank you

Hi Alesia,

This code works fine with chrome driver,but when we use the same capability with universal driver I am getting the below exception,

m.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions

Below is the code I am using:

<robotics-flow>
		<robot name="webDriver" driver="universal" close-on-completion="true"
			maximize-on-startup="true" start-in-private="false">
			  <capability name="SEARCH_ALL_WINDOWS" value="true"/> 
			<capability name="ChromeOptions">
                           <script return="chromeArgs"><![CDATA[
                                  import com.workfusion.common.browser.UniversalBrowser;
                                  import java.util.Hashtable;
                                  import org.openqa.selenium.remote.DesiredCapabilities;
                                  
                                  import org.openqa.selenium.chrome.ChromeOptions;
                                 ChromeOptions options = new ChromeOptions();
                                  //UniversalBrowser options=new UniversalBrowser();
                                  options.addArguments("--disable-notifications");
                                  Map<String, Object> chromePrefs = new Hashtable<String, Object>();
                                  chromePrefs.put("profile.default_content_settings.popups", 0);
                                  chromePrefs.put("download.prompt_for_download", true);                             
                                  options.setExperimentalOption("prefs", chromePrefs);
                                  options.addArguments("disable-infobars");
                                  chromeArgs = options;
                           ]]></script>
                     </capability>

@kiran.talreja what version of RPA Express are you using?