首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用selenium remote webdriver在隐身模式下启动Edge浏览器?

如何使用selenium remote webdriver在隐身模式下启动Edge浏览器?
EN

Stack Overflow用户
提问于 2016-04-11 19:53:01
回答 2查看 5.1K关注 0票数 3

目前,我们正在使用使用C#的Edge browser开发selenium (2.53.0)。边缘浏览器将缓存信息存储在'localAppdata‘文件夹中,由于缓存的存在,我们在测试用例执行时会遇到一些问题。

我尝试使用selenium (DeleteAllCookies)删除所有cookies信息,但它不适用于边缘浏览器。

我读了几个微软论坛,当我们在匿名模式下启动Edge浏览器时,跳过缓存的唯一方法。

有没有人可以建议如何使用selenium remote-webdriver在私有模式(匿名模式)下启动Edge浏览器实例

EN

回答 2

Stack Overflow用户

发布于 2018-12-28 04:38:41

如果你想在私密(匿名)模式下打开边缘,你可以使用这个C#代码:

代码语言:javascript
复制
EdgeOptions options = new EdgeOptions();
options.AddAdditionalCapability("InPrivate", true);
this.edgeDriver = new EdgeDriver(options);
票数 3
EN

Stack Overflow用户

发布于 2021-05-11 19:27:04

下面是我在设置EdgeDriver实例时使用的一个示例。(C#)

代码语言:javascript
复制
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;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36547933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档