This is a migrated thread and some comments may be shown as answers.

Why in last TestStudio version cookie deletion doesn't work?

1 Answer 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
it4me
Top achievements
Rank 1
it4me asked on 15 Jun 2011, 09:37 PM
Hello!
I have a simple case, but i've spent 1,5 hours trying to resolve it - no success!

The case is: login in gmail.com several times under different users.
After first login need to clear cookies, but the ActiveBrowser.Cookies.DeleteCookie - doesn't work in IE.

I found a lot of topics, but no one helps.
http://www.artoftest.com/community/forums/webaii--web-automation-infrastructure/forum-general-questions/cannot-delete-cookies.aspx
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/telerik-testing-framework/intermediate-topics/cookie-support.aspx
My browsers are: IE8.0, Chrome12, Firefox4.0, Safari 5.0.5
The code is:
Manager.LaunchNewBrowser();
           System.Net.CookieCollection gCookie1 = ActiveBrowser.Cookies.GetCookies("http://google.com");
           System.Net.CookieCollection gCookie2 = ActiveBrowser.Cookies.GetCookies("http://www.google.com");
           System.Net.CookieCollection gCookie3 = ActiveBrowser.Cookies.GetCookies("http://www.accounts.google.com");
            
           foreach (System.Net.Cookie cookie in appCookie)
           {
               ActiveBrowser.Cookies.DeleteCookie(cookie);
           }
 
           foreach (System.Net.Cookie cookie in gCookie1)
           {
               ActiveBrowser.Cookies.DeleteCookie(cookie);
           }
            
           foreach (System.Net.Cookie cookie in gCookie2)
           {
               ActiveBrowser.Cookies.DeleteCookie(cookie);
           }
 
           foreach (System.Net.Cookie cookie in gCookie3)
           {
               ActiveBrowser.Cookies.DeleteCookie(cookie);
           }
 
           ActiveBrowser.NavigateTo("https://www.google.com/accounts/ServiceLogin");

This work in chrome, safari,firefox, but not works in IE8.0

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 22 Jun 2011, 12:18 AM
Hi it4me,

IE is more sensitive to the URI you pass in than the other browsers. Try this code instead:

System.Net.CookieCollection gCookie2 = ActiveBrowser.Cookies.GetCookies("https://www.google.com/accounts/");
foreach (System.Net.Cookie cookie in gCookie2)
{
    ActiveBrowser.Cookies.DeleteCookie(cookie);
}

Kind regards,
Cody
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
Tags
General Discussions
Asked by
it4me
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or