Restrict IE from asking save dialogue pop up and it should save automatically in selenium c#

0

Have added image for referenceAm automating a functionality where on button click the IE download the file with a dialogue box pop with save /open and cancel instead i want to download the file automatically to a specific location in selenium C#. as am not much interested in automating the save dialogue box part.. I get fix for Mozilla and chrome no such options for IE. any links or ideas will be helpful.

Kamila

Posted 2019-08-30T07:20:29.010

Reputation: 1

Answers

0

I would recommend reconsidering your approach as file download functionality is not something you should cover with tests as it is rather testing of IE browser than your application.

From the other hand if you need the information from the file or want to check its integrity there is an alternative way of downloading it.

  1. Obtain its href or download or src attribute via IWebElement.GetAttribute() function - this way you will obtain the link to your .csv file
  2. Use HttpClient to download the file and store it to the desired location

If your site assumes authentication you can get the relevant Cookies from the browser via driver.Manage().Cookies property and add the relevant Cookie header to the HttpClient containing the cookies from the real browser session.

Dmitri T

Posted 2019-08-30T07:20:29.010

Reputation: 411

Thanks ,There are no changes happenign in my href to capture as it just gets downloaded , my html looks like so .. <a onclick="return ShowExportWarning();" id="btnExport" class="black-button pcb" href="javascript:__doPostBack('btnExport','')"><span>Export</span></a> – Kamila – 2019-08-30T10:05:43.193