c# - 接受 C# selenium 中的证书 (.p12)
问题描述
我正在尝试找到一种方法来接受 C# selenium 中的证书弹出窗口。
我尝试了几种方法..没有任何帮助。
new Thread(() =>
{
driver.Navigate().GoToUrl(url);
}).Start();
driver.SwitchTo().Alert().Accept(); // here I tried many type of ways to accept the popup, also key:enter ...
我也尝试了一些忽略的东西来添加,
chromeOptions.AddArguments();
但它也没有帮助。
有几个想法是不实际的 - 例如DesiredCapabilities
不再可用。
没有帮助:
options.AddArgument("ignore-certificate-errors");
chromeOptions.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
感谢您的任何想法或支持
解决方案
以下代码有效(选项名称开头带有“--”):
var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--ignore-certificate-errors");
var chromeDriverLocation = Environment.GetEnvironmentVariable("ChromeWebDriver");
if (string.IsNullOrEmpty(chromeDriverLocation))
{
chromeDriverLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
}
WebDriver = new ChromeDriver(chromeDriverLocation, chromeOptions);
(完整代码在这里)
推荐阅读
- javascript - 过滤对象javascript的嵌套数组
- azure - Azure ApplicationGateWay requestRoutingRules 在已定义时不是引用
- reactjs - 根据另一个 ag-grid 中的选定行过滤 ag-grid
- node.js - 为什么当我将 React 表单设置为 multipart/form-data 时,它会被视为 application/json?我上传的文件被视为未定义
- matlab - 计算实函数的值,但结果是复数
- graphql - 来自 shopify 的 Gatsby graphQL 没有返回对象
- tensorflow - 为什么 resnet50 的 MaxPool2d 层在 tensorboard 中可视化时会输出 2 个张量?
- input - 我在这段代码中遗漏了什么,它看起来不错并且格式正确吗?
- python - 我不知道为什么python无法检测到pynput
- tensorflow - 如何使用 LSTM 屏蔽多变量时间序列分类中的填充值