0

I want to save a login cookie in first time , then load it next times so the i won't have to perform a login each time.

Any Idea?

public void mControlClick()
        {
            var options = new ChromeOptions();
            var chromeDriver = new ChromeDriver(options);
            chromeDriver.Navigate().GoToUrl("http://website.com")


        }
Dr.Mezo
  • 807
  • 3
  • 10
  • 25
  • Possible duplicate of [Saving chrome cookies Selenium](https://stackoverflow.com/questions/39183753/saving-chrome-cookies-selenium) – Manmohan_singh Jun 01 '18 at 04:11

1 Answers1

1

I had a similar issue. Watching with the developer window, I could see that after login a cookie was being sent but then the page via javascript or something else was redirecting before returning control to the program. So, I was unable to get that cookie and save it off.

After more research I realised that the program was starting with a clean session each time (this answer helped a lot) so the persistent cookies weren't persistent at all. It took further research, but giving selenium (via splinter) a profile to work with resolved my issue. I am actually using python, but I'm sure the options still follow for C#

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-data-dir=" + tdir + "/chrome-session")
chrome_options.add_argument("--profile-directory=Default")
with Browser('chrome', headless=True, options=chrome_options) as browser:
Bryan
  • 295
  • 1
  • 2
  • 9