Selenium webdriver Selenium Webdriver:如何获取当前页面中的所有cookie

Selenium webdriver Selenium Webdriver:如何获取当前页面中的所有cookie,selenium-webdriver,Selenium Webdriver,尝试使用带有java的Chrome驱动程序获取当前页面中的所有cookie。 关闭浏览器并尝试使用旧cookie打开新浏览器后,请帮助我检索一次页面中的所有cookie。使用WebDriver API,网址为: 获取当前页面的所有cookie并解析到cookie对象集合: driver.manage().getCookies(); //TODO Parse results to Cookie Objects and Do what you want 使用WebDriver

尝试使用带有java的Chrome驱动程序获取当前页面中的所有cookie。
关闭浏览器并尝试使用旧cookie打开新浏览器后,请帮助我检索一次页面中的所有cookie。

使用WebDriver API,网址为:

获取当前页面的所有cookie并解析到cookie对象集合:

     driver.manage().getCookies();
    //TODO Parse results to Cookie Objects and Do what you want

使用WebDriver API可从以下网址获得:

获取当前页面的所有cookie并解析到cookie对象集合:

     driver.manage().getCookies();
    //TODO Parse results to Cookie Objects and Do what you want

从所有域获取cookie 在自动化测试中,我们可能需要验证网站的cookies

Webdriver具有简单而强大的API来检索当前页面域的cookie。以下是读取Cookie的示例代码:

public Dictionary<string, string> GetAllPageCookies()
        {
            return _driver.Manage().Cookies.AllCookies.ToDictionary(cookie => cookie.Name, cookie => cookie.Value);
        }
公共字典GetAllPageCookies()
{
返回_driver.Manage().Cookies.AllCookies.ToDictionary(cookie=>cookie.Name,cookie=>cookie.Value);
}

从所有域获取cookie 在自动化测试中,我们可能需要验证网站的cookies

Webdriver具有简单而强大的API来检索当前页面域的cookie。以下是读取Cookie的示例代码:

public Dictionary<string, string> GetAllPageCookies()
        {
            return _driver.Manage().Cookies.AllCookies.ToDictionary(cookie => cookie.Name, cookie => cookie.Value);
        }
公共字典GetAllPageCookies()
{
返回_driver.Manage().Cookies.AllCookies.ToDictionary(cookie=>cookie.Name,cookie=>cookie.Value);
}

这适用于域内的Cookie,但不会提供来自第三方域的Cookie。因此,不,它不是所有的cookie,不管属性名称:(这适用于您域内的cookie,但不会提供来自第三方域的cookie。因此,不,它不是所有cookie,不管属性名称:(