public static void addCookieByByte(byte[] arrByte, IWebDriver oIWebDriver) { var lstCookieEx = (List <Dictionary <string, object> >)SerialUtilsEx.deserializeObject(arrByte); foreach (var mapCookie in lstCookieEx) { var oCookie = Cookie.FromDictionary(mapCookie); ICookieJar oICookieJar = oIWebDriver.Manage().Cookies; oICookieJar.AddCookie(oCookie); } }
public static byte[] getAllCookies4Byte(IWebDriver oIWebDriver) { ReadOnlyCollection <Cookie> lstCookie = oIWebDriver.Manage().Cookies.AllCookies; List <Dictionary <string, object> > lstCookieEx = new List <Dictionary <string, object> >(); foreach (var oCookie in lstCookie) { var mapCookie = new Dictionary <string, object>(); mapCookie.Add("domain", oCookie.Domain); mapCookie.Add("expiry", oCookie.Expiry); mapCookie.Add("name", oCookie.Name); mapCookie.Add("path", oCookie.Path); mapCookie.Add("Secure", oCookie.Secure); mapCookie.Add("value", oCookie.Value); lstCookieEx.Add(mapCookie); } var arrRes = SerialUtilsEx.serializeObject(lstCookieEx); return(arrRes); }