如何使用 Selenium Web Driver 和 C# 清除浏览器 cookie

2024-05-02

正如标题,如何使用 Selenium Web Driver 和 C# 清除浏览器 cookie?

IWebDriver driver = new FirefoxDriver();
driver.Manage().Cookies.DeleteAllCookies(); //delete all cookies
System.Threading.Thread.Sleep(5000);

我尝试了上面的代码,但它没有删除会话数据。


我认为代码是:-

driver.manage().deleteAllCookies();

not

driver.Manage().Cookies.DeleteAllCookies();

OR

使用相同的 Firefox 配置文件进行试用:

  1. 驱动程序.close();

  2. 驱动程序 = new FirefoxDriver(SeleniumObject.firefoxprofile); // 使用先前会话启动时使用的配置文件。

  3. driver.get(AppURL);

    • 浏览器关闭。
    • 饼干正在丢失。

尝试使用 get(""):

  1. 驱动程序.get("");

  2. driver.get(AppURL);

希望它能帮助你:)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 Selenium Web Driver 和 C# 清除浏览器 cookie 的相关文章

随机推荐