Benjamin-Loison / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
0 stars 0 forks source link

[🚀 Feature]: Add cookies without visiting the given URL #3

Open Benjamin-Loison opened 10 months ago

Benjamin-Loison commented 10 months ago

Feature and motivation

For speed and more discreet reasons.

browser.add_cookie({'name': 'COOKIE_NAME', 'value': 'COOKIE_VALUE'})
Output: ``` Traceback (most recent call last): File "", line 1, in File "/home/benjamin/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in add_cookie self.execute(Command.ADD_COOKIE, {"cookie": cookie_dict}) File "/home/benjamin/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute self.error_handler.check_response(response) File "/home/benjamin/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidCookieDomainException: Message: Document is cookie-averse Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:191:5 InvalidCookieDomainError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:398:5 GeckoDriver.prototype.addCookie@chrome://remote/content/marionette/driver.sys.mjs:2120:11 ```

Usage example

Not read.

Benjamin-Loison commented 5 days ago

Would help Webscrap_any_website/issues/67.