Hi
I can set the cookie with domain "ctrip.com" when testing in FireFox, but couldn't set the value with domain which likes ".ctrip.com".
//the following codes works well
Cookie cookie =
new
Cookie();
cookie.Domain =
"ctrip.com"
;
cookie.Name = cookieName;
cookie.Value = cookieValue;
cookie.Path =
"/"
;
cookie.Expires = DateTime.Now.AddHours(2);
Manager.ActiveBrowser.Cookies.SetCookie(cookie);
//the following codes doesn't work, after executing the codes, I couln't find the cooke.
Cookie cookie =
new
Cookie();
cookie.Domain =
".ctrip.com"
;
cookie.Name = cookieName;
cookie.Value = cookieValue;
cookie.Path =
"/"
;
cookie.Expires = DateTime.Now.AddHours(2);
Manager.ActiveBrowser.Cookies.SetCookie(cookie);
Thanks in advance.
5 Answers, 1 is accepted
Thank you for the question.
I'm sorry to hear you're hitting this problem. The reason is in our implementation of the SetCookie method. We will discuss how to improve the implementation of the method in the shortest time.
However I found a workaround. You can add this coded step in order to set cookies for every domain or subdomain you want. Note that this is for the current page.
string setCookieFunc = string.Format("var c_name ='{0}';var value = '{1}';var exdays = {2};var exdate=new Date();exdate.setDate(exdate.getDate() + exdays);var c_value=escape(value) + ((exdays==null) ? '' : '; expires='+exdate.toUTCString());document.cookie=c_name + '=' + c_value;", "Name", "Value", 1);
this.ActiveBrowser.Actions.InvokeScript(setCookieFunc);
Boyan Boev
the Telerik team
Test Studio Trainings
Let me know whether it helps.
If you have any further questions feel free to contact us.
Boyan Boev
the Telerik team
Test Studio Trainings
It works well.
Glad I could help. Let me know if I can assist further.
Kind regards,
Boyan Boev
the Telerik team
Test Studio Trainings