i would like to download file in pdf with selenium edge web driver in specific custom folder in c# selenium

Rakesh kumar 106 Reputation points

I am new to selenium and i would like to download file in pdf with selenium edge web driver in specific custom folder. In default the file is downloading in browser specified download path. Any one suggest the best solution for downloading file in custom path in C# Selenium.

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,627 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jack J Jun 24,496 Reputation points Microsoft Vendor

    @Rakesh kumar , Welcome to Microsoft Q&A. you could try the following code to download file to specific custom folder by using selenium.

    var options = new ChromeOptions();  
        string downloadFilePath = @"E:\Test";  
        options.AddUserProfilePreference("download.default_directory", downloadFilePath);  
        options.AddUserProfilePreference("intl.accept_languages", "nl");  
        options.AddUserProfilePreference("disable-popup-blocking", "true");  
        // declare driver with these options  
        var driver = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory, options);  
        var reportDownloadButton = driver.FindElement(OpenQA.Selenium.By.CssSelector("div[itemtype='http://schema.org/Offer']"));  

    I used website instead of pdf, but they are fundamentally the same.



    Hope the above code could help you.

    Best Regards,

0 additional answers

Sort by: Most helpful