K
K
kos_dev2017-03-25 19:41:23
In contact with
kos_dev, 2017-03-25 19:41:23

How to get cookies from the site and use them in other sessions?

Hello, tell me how can I get cookies and use them later in Selenium Webdriver. The task is as follows:
- I went to https://vk.com/
- I logged in manually
- I got cookies
- I restarted the driver (in order to clear cookies)
- I went to https://vk.com/
- I logged in by adding cookies.
My attempts are receiving cookies:

remixlang:0
remixdt:0
remixsid: ....fsadgwgrge41231241r...
remixsslsid:1
remixflash:25.0.0
remixscreen_depth:24
remixseenads:1

The code for inserting cookies looks something like this:
driver.Quit();
            driver = null;
            driver = new FirefoxDriver();

            driver.Manage().Cookies.DeleteAllCookies();
            foreach (Cookie ck in cookie)
            {
                try
                {
                    driver.Manage().Cookies.AddCookie(ck);
                }
                catch (Exception ex)
                {
                    textBox1.Text += ex.ToString() + Environment.NewLine;
                }
            }
            driver.Navigate().GoToUrl("https://vk.com/");

Thank you in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question