What I want to do is to open a page (for example youtube) and be automatically logged in, like when I manually open it in the browser.
From what I've understood, I have to use cookies, the problem is that I can't understand how.
I tried to download youtube cookies with this:
driver = webdriver.Firefox(executable_path="driver/geckodriver.exe")
driver.get("https://www.youtube.com/")
print(driver.get_cookies())
And what I get is:
{'name': 'VISITOR_INFO1_LIVE', 'value': 'EDkAwwhbDKQ', 'path': '/', 'domain': '.youtube.com', 'expiry': None, 'secure': False, 'httpOnly': True}
So what cookie do I have to load to automatically log in?
You can use
pickle
to save cookies as text file and load it later:I ever met the same issue. Finally I use the chromeoptions to fix this issue instead of cookie file.
try this, there is a method to add cookie to your driver session
http://selenium-python.readthedocs.io/api.html#selenium.webdriver.remote.webdriver.WebDriver.add_cookie