Ak02
Ak02

Reputation: 161

how to current get download path from browser settings

I need to get the current download path from browser settings (chrome,firefox,IE) in C#. I am working with selenium and having some tests which contains file download option. I am able to download the file successfully via my test but having issue with the verification with file download. I have no way to verify whether the download was successful or not. So I am thinking to get the current download location of the browser which most of the time will be "\\downloads" and to check for the file exists at the location first.

I will be executing my tests on different servers and browsers so I cant relay on the static "\\downloads" location need to get the current download path from the browser. is there any way I can get this download path in C# with the selenium webdriver.

Upvotes: 1

Views: 4268

Answers (1)

Jordan Benyon
Jordan Benyon

Reputation: 320

This is how to get the Downloads path,

string user = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string download = Path.Combine(user, "Downloads");

EDIT: This could be useful to you. How to find browser download folder path

Upvotes: 2

Related Questions