我正在尝试使用 edgewebdriver 和 selenium 将网页下载为 pdf。现在,边缘配置为 OneNote(桌面),如图所示
我想在单击打印按钮之前更改对话框中的下拉值。这是我正在初始化驱动程序的构造函数代码
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);
}
我参考了以下链接 Chrome prefs list
我完全被卡住了,找不到任何解决问题的方法。每次出现“打印”对话框时,它都会尝试保存到 OneNode(桌面)。