tryolabs / requestium

Integration layer between Requests and Selenium for automation of web actions.
BSD 3-Clause "New" or "Revised" License
1.83k stars 147 forks source link

error with transfer_session_cookies_to_driver() #41

Closed Abd0s closed 2 years ago

Abd0s commented 5 years ago

When I try to use transfer_session_cookies_to_driver() to transfer my session to a driver I get the following error. Seems like this is a bug with the lib?

  File "src\gevent\greenlet.py", line 716, in gevent._greenlet.Greenlet.run
  File "C:\Users\Abdos\AppData\Local\Programs\Python\Python36\lib\site-packages\eel\__init__.py", line 191, in _process_message
    return_val = _exposed_functions[message['name']](*message['args'])
  File "C:\Users\Abdos\Documents\GitHub\Bol.com-AIbot\src\main.py", line 113, in bot_start
    s.transfer_session_cookies_to_driver()
  File "C:\Users\Abdos\AppData\Local\Programs\Python\Python36\lib\site-packages\requestium\requestium.py", line 114, in transfer_session_cookies_to_driver
    'expiry': c.expires, 'domain': c.domain})
  File "C:\Users\Abdos\AppData\Local\Programs\Python\Python36\lib\site-packages\requestium\requestium.py", line 235, in ensure_add_cookie
    self.add_cookie(cookie)
  File "C:\Users\Abdos\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 894, in add_cookie
    self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
  File "C:\Users\Abdos\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Abdos\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid 'expiry'
jimmy927 commented 5 years ago

I got the same issue.

This fix solves the issue for now, not really sure about the implications though, but i use it.

https://github.com/jimmy927/requestium/commit/596db69d18926981df23988e96ca33c361badb40

jschnurr commented 5 years ago

As described in detail here, the cookie specs say values should not be null, and chromedriver 2.46 started enforcing that. To resolve, we remove any properties of the cookie with a value of None before invoking the webdriver.

Resolved by PR #42.

hffaust commented 5 years ago

I actually encountered this error and fixed it by simply changing 'expiry' to 'expires' ...

OYin-Quest commented 4 years ago

I actually encountered this error and fixed it by simply changing 'expiry' to 'expires' ...

Is the 'expiry/expires' value correctly set in cookie? I change 'expiry' to 'expires' can bypass the error, but value is not set correctly. (using chrome driver 78.0.3904.108)