Unable to change Printer value to “Save as PDF” in edge using selenium
I am trying to download a web page as pdf using edgewebdriver and selenium. Now, the edge is configured to a OneNote(Desktop)
I want to change the dropdown value in the dialog before clicking on the print button. This is the constructor code where I am initializing the driver
public Driver(bool headLess = true)
{
var driverPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Driver");
var chromeDriverService = EdgeDriverService.CreateChromiumService(driverPath);
chromeDriverService.HideCommandPromptWindow = true;
var edgeOptions = new EdgeOptions();
edgeOptions.UseChromium = true;
var appState = new AppState()
{
recentDestinations = new List<RecentDestination>()
{
new RecentDestination(){ id = "Save as PDF", origin ="local", account = ""}
},
selectedDestinationId = "Save as PDF",
version = 2
};
edgeOptions.AddUserProfilePreference("printing.print_preview_sticky_settings", appState);
edgeOptions.AddArguments("kiosk-printing");
if (headLess)
{
edgeOptions.AddArgument("headless");
}
this._driver = new EdgeDriver(chromeDriverService, edgeOptions);
}
I have referred the following link https://chromium.googlesource.com/chromium/src/+/refs/heads/main/chrome/common/pref_names.cc
I am totally stuck and can't find any solution to the problem. Every time "Print" dialog comes but the it tries to save to OneNode(Desktop).