tryolabs/requestium

Switch cookies from Session to driver not working on Instagram

TheGlobalist opened this issue · 4 comments

Hi all,

This is more a question than an issue.
I'm trying to implement requestium to do some operations between the Session object and the driver object on Instagram.com.
As I successfully manage to login inside the website through Session, it seems that it blocks me in switching to the driver in order to have the already logged in page.
This is the error that the console prints me

DevTools listening on ws://127.0.0.1:12779/devtools/browser/73b726a1-520f-4d08-8982-a9ada65ead2b
Traceback (most recent call last):
  File "requestiumTest.py", line 124, in <module>
    s.transfer_session_cookies_to_driver()  # You can maintain the session if needed
  File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\requestium\requestium.py", line 114, in transfer_session_cookies_to_driver
    'expiry': c.expires, 'domain': c.domain})
  File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\requestium\requestium.py", line 235, in ensure_add_cookie
    self.add_cookie(cookie)
  File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 872, in add_cookie
    self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
  File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
  (Session info: chrome=66.0.3359.139)
  (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.15063 x86_64)

And this is all the script to reproduce it, if interested

https://pastebin.com/TwEn9T5B

Hi, @TheGlobalist, I have the same issue as you. Did you find a solution?

@ValentinPerret Nope, in the end I had to do the opposite: logging in via Selenium and then switching cookies

Does this patch fixes your issue ?

jimmy927@596db69

Closing as stale. Please reopen with more details if the problem persists.