C# selenium chromedriver click on Allow store files on this device

Found two solutions:

1) Thanks for @Floren 's answer: C# selenium chromedriver click on Allow store files on this device

There is an argument for Chromium --unlimited-storage

Chromium source code reference:

// Overrides per-origin quota settings to unlimited storage for any
// apps/origins.  This should be used only for testing purpose.
const char kUnlimitedStorage[] = "unlimited-storage";



# Prevent the infobar that shows up when requesting filesystem quota.
    '--unlimited-storage',

C# usage:

var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--unlimited-storage");
var driver = new ChromeDriver(chromeOptions);

2) @Simon Mourier's answer C# selenium chromedriver click on Allow store files on this device

Click on Allow button using .NET UIAutomation

var andCondition = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), new PropertyCondition(AutomationElement.NameProperty, "Allow"));

AutomationElement chromeWindow = AutomationElement.FromHandle(_windowPointer); // IntPtr type
var buttonsFound = chromeWindow.FindAll(TreeScope.Descendants,  andCondition);
if (buttonsFound.Count > 0)
{
   var button = buttonsFound[0];
   var clickPattern = button.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
   clickPattern.Invoke();
}

You can't, this is an OS level dialogue, not something inside the DOM.

The way to get around it is by using desired capabilities to configure chrome to not show this dialogue.

I'm going to suggest

ChromeOptions options = new ChromeOptions();
options.AddUserProfilePreference("download.prompt_for_download", 0);
options.AddUserProfilePreference("settings.labs.advanced_filesystem", 1);

Other potential commands to add the options if AddUserProfilePreference doesn't work would be:

  • AddLocalStatePreference
  • AddAdditionalChromeOption
  • AddAdditionalCapability

For more details about desired capabilities and chrome have a look at:

  • The ChromeOptions documentation
  • This list of command line switches, or the command line switched defined directly in code.
  • The preferences defined directly in code
  • The ChromeOptions class in the Selenium codebase

        var chromeOptions = new ChromeOptions();
        var downloadDirectory = @"C:\Users\";



        chromeOptions.AddUserProfilePreference("download.default_directory", downloadDirectory);
        chromeOptions.AddUserProfilePreference("download.prompt_for_download", false);
        chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true");


        chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.automatic_downloads", 1);

        IWebDriver _driver = new ChromeDriver(chromeOptions);

Can you try with this one ?