How do you stay logged in with the Selenium Chrome browser?

Viewed 703

I use the following code to open a Chrome window using Selenium:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.youtube.com/")

However, whenever I enter the site, I am logged out. On other sites, I can manually do so, but Google deems it unsafe to log in with Selenium.

I know that Selenium is a test browser, but is it possible to stay logged in with Selenium so that I can access my user data; or is that not the purpose of Selenium, and calling the Chrome subprocess the way to go?

1 Answers

To start with Selenium isn't a browser as such but a bunch of libraries which helps in simulating Browsing Context.

From the question it's not that clear why you are logged out once you login in to the site. But definitely once you are logged in using Selenium driven ChromeDriver initiated Browsing Context you must remain logged in and should be able to access your user data.

Related