WebDriverException: Message: unable to set cookie while switching cookies from Session to Selenium's Chrome on Instagram WebDriverException: Message: unable to set cookie while switching cookies from Session to Selenium's Chrome on Instagram selenium selenium

WebDriverException: Message: unable to set cookie while switching cookies from Session to Selenium's Chrome on Instagram


I was running into the same error using requests and selenium. You need to get a page on the domain first before you can set the cookies

driver.get(login_url)for cookie in s.cookies:    driver.add_cookie({        'name': cookie.name,         'value': cookie.value,        'domain': cookie.domain    })driver.get(dashboard_url)


This error message...

selenium.common.exceptions.WebDriverException: Message: unable to set cookie

...implies that WebDriverException was raised while trying to set cookie.

The cookie error seems to be coming out of the version compatibility between the binaries you are using as follows :

  • You are using chromedriver=2.36
  • Release Notes of chromedriver=2.36 clearly mentions the following :

Supports Chrome v63-65

  • You are using chrome=66.0
  • Release Notes of ChromeDriver v2.38 clearly mentions the following :

Supports Chrome v65-67

So there is a clear mismatch between the ChromeDriver version (v2.36) and the Chrome Browser version (v66.0)

Solution

  • Upgrade ChromeDriver to current ChromeDriver v2.38 level.
  • Keep Chrome version at Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test.


Apparently there's no solution to this, even after DebanjanB's answer.I found a workaround which perfectly works for me though: logging in through Selenium and then switch the cookies to the Session object of requestium and viceversa works perfectly.