Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the default downloads folder path using Selenium WebDriver

I am new to selenium and I would like to know how do I get the default path of the downloads folder of the browser(I'm using chrome) in the operating system.

I just found a way to set the default path like this:

 var chromeOptions = new ChromeOptions();
 chromeOptions.AddUserProfilePreference("download.default_directory", path);
 chromeOptions.AddUserProfilePreference("intl.accept_languages", "nl");
 chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true");
 var driver = new ChromeDriver("Driver_Path", chromeOptions);
like image 863
GroundIns Avatar asked Mar 17 '16 14:03

GroundIns


People also ask

How to download files to a specified location with selenium Python?

We can download files to a specified location with Selenium in Python. This is done by the help of the ChromeOptions class. We shall set the preferences of the browser and pass the download.default_directory parameter.

Can selenium change the default download path?

Selenium download path is also the same as the local download path it saves in the downloads folder. Selenium can change the default download directory. When done manually, it is useless as the driver always opens up with default settings. It won't be the same as when we made the change. So it has to be in the programming level change.

What is selenium selenium webdriver?

Selenium will help to download the file via the WebDriver to the location specified as a browser capability. However, after downloading, verifications are done using IO operations or Input-Output operations. Therefore we use file reading mechanisms provided by Java libraries to read and assert file-related operations.

How to specify a custom file download location in Edge using WebDriver?

First of all, let’s look at how to specify a custom file download location in edge using WebDriver. There is one discrepancy in the edge driver compared to the chrome. If you are using the selenium 3.x.x version, you need to add the below dependency in your pom.xml Then, you need to create a map and add the preferences as key-value pairs.


1 Answers

2 ways of achieving this.

One can be found here: Find Chrome Path

Seconds is to type on browswer (can do that via sendKeys):

chrome://settings

then instruct your webdriver to click on 'advanced' and finally you can grab the default download directory from the 'location'

If you get stuck anywhere or want further help, please let me know. Best of luck!

like image 157
Xwris Stoixeia Avatar answered Sep 19 '22 18:09

Xwris Stoixeia