C# Selenium add cookies from json file

Viewed 238

How do i add cookies to selenium in c#. like this python code add cookies from json file.

Python:

with open(js_cookie_path, "r") as cp:
    cookie = json.loads(cp.read())
    for c in cookie:
        driver.add_cookie(c)

c#

dynamic cookie = JsonConvert.DeserializeObject(File.ReadAllText(js_cookie_path));
foreach (dynamic c in cookie) {
   Driver.Manage().Cookies.AddCookie(c)
}
0 Answers
Related