Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML file downloads are blocked #133

Open
RajeshPoola opened this issue Jan 5, 2024 · 2 comments
Open

XML file downloads are blocked #133

RajeshPoola opened this issue Jan 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@RajeshPoola
Copy link

While using InPrivate mode, downloading XML files triggers a security pop-up showing the file download blocked message.

I used the following options but they didn't work. I didn't find any documentation regarding this.

var options = new EdgeOptions();
options.AddArgument("--safebrowsing-disable-download-protection");
options.AddUserProfilePreference("download.prompt_for_download", false);
options.AddUserProfilePreference("savefile.default_directory", OutputFilePath);
![Screenshot 2024-01-05 110535](https://github.com/MicrosoftEdge/EdgeWebDriver/assets/82456213/e781eb22-fca9-47a7-a698-69afe8cfc033)

options.AddUserProfilePreference("savefile.prompt_for_download", false);
@RajeshPoola RajeshPoola added the bug Something isn't working label Jan 5, 2024
@Ssloan18
Copy link

Ssloan18 commented Jan 9, 2025

Hi @RajeshPoola

I’m facing the exact same issue as you with XML files being blocked during download. I would love to know how you managed to solve this issue? Any tips or guidance would be greatly appreciated.

Thanks in advance for your response!

@RajeshPoola
Copy link
Author

RajeshPoola commented Jan 9, 2025

Hi @RajeshPoola

I’m facing the exact same issue as you with XML files being blocked during download. I would love to know how you managed to solve this issue? Any tips or guidance would be greatly appreciated.

Thanks in advance for your response!

@Ssloan18 If you have admin access on your machine you can try this. Call this method before setting up driver

private static void AllowEdgeToDownloadXmlFiles()
{
    // Define the registry path and value
    const string regPath = @"SOFTWARE\Policies\Microsoft\Edge";
    const string regName = "ExemptFileTypeDownloadWarnings";
    const string regValue = "[ { \"file_extension\": \"xml\", \"domains\": [\"azurefd.net\"] } ]";

    try
    {
        // Open or create the registry key
        using var key = Registry.LocalMachine.CreateSubKey(regPath);
        if (key != null)
        {
            // Set the registry value
            key.SetValue(regName, regValue, RegistryValueKind.String);
            Console.WriteLine("Registry key set successfully.");
        }
        else
        {
            throw new ApplicationException("Failed to create or open the registry key.");
        }
    }
    catch (UnauthorizedAccessException)
    {
        throw new ApplicationException(
            "Access to the registry key is denied. Please run the program as an administrator.");
    }
    catch (Exception ex)
    {
		throw new UnauthorizedAccessException("An error occurred: " + ex.Message);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants