目前,我们正在使用使用C#的Edge browser开发selenium (2.53.0)。边缘浏览器将缓存信息存储在'localAppdata‘文件夹中,由于缓存的存在,我们在测试用例执行时会遇到一些问题。
我尝试使用selenium (DeleteAllCookies)删除所有cookies信息,但它不适用于边缘浏览器。
我读了几个微软论坛,当我们在匿名模式下启动Edge浏览器时,跳过缓存的唯一方法。
有没有人可以建议如何使用selenium remote-webdriver在私有模式(匿名模式)下启动Edge浏览器实例
发布于 2018-12-28 04:38:41
如果你想在私密(匿名)模式下打开边缘,你可以使用这个C#代码:
EdgeOptions options = new EdgeOptions();
options.AddAdditionalCapability("InPrivate", true);
this.edgeDriver = new EdgeDriver(options);发布于 2021-05-11 19:27:04
下面是我在设置EdgeDriver实例时使用的一个示例。(C#)
private IWebDriver SetupEdgeWebDriver(bool runHeadlessOnPipeline, int implicitWait = 12500)
{
IWebDriver webDriverInstance;
EdgeOptions edgeOptions = new EdgeOptions
{
//Microsoft Edge (Chromium)
UseChromium = true
};
if (EnableIncognito)
{
edgeOptions.AddArgument("inprivate");
}
edgeOptions.BinaryLocation = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe";
//azure devops pipeline
if (PipelineRun)
{
edgeOptions.AddArgument("disable-gpu");
edgeOptions.AddArgument("window-size=1920,960");
if (runHeadlessOnPipeline)
{
edgeOptions.AddArgument("headless");
}
}
//running on your local machine
else
{
edgeOptions.AddArgument("start-maximized");
}
edgeOptions.SetLoggingPreference(LogType.Driver, LogLevel.Debug);
webDriverInstance = new EdgeDriver(edgeOptions);
webDriverInstance.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(implicitWait);
return webDriverInstance;
}https://stackoverflow.com/questions/36547933
复制相似问题