Reputation: 16416
I'm setting the user director to be my default User data directory as such (so I don't have to worry about entering passwords to sites and logging in each time):
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=~/Library/Application\ Support/Google/Chrome/Default/")
browser = webdriver.Chrome(options=options, executable_path=r"chromedriver")
browser.get('https://mail.google.com/mail/u/0/')
print browser.desired_capabilities
Now I would expect my Gmail to come up but it asks me to sign in.
Further, when I print the desired capabilities it appears that the user data directory has NOT been set at all:
{u'takesScreenshot': True, u'acceptSslCerts': True, u'networkConnectionEnabled': False, u'mobileEmulationEnabled': False, u'unexpectedAlertBehaviour': u'', u'applicationCacheEnabled': False, u'locationContextEnabled': True, u'rotatable': False, u'chrome': {u'chromedriverVersion': u'2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b)', u'userDataDir': u'/var/folders/2r/twg_2d4j5cnf2d6k1m_mnx4c0000gn/T/.org.chromium.Chromium.ihUqp7'}, u'hasTouchScreen': False, u'platform': u'Mac OS X', u'version': u'70.0.3538.110', u'nativeEvents': True, u'handlesAlerts': True, u'takesHeapSnapshot': True, u'javascriptEnabled': True, u'databaseEnabled': False, u'browserName': u'chrome', u'webStorageEnabled': True, u'browserConnectionEnabled': False, u'cssSelectorsEnabled': True, u'pageLoadStrategy': u'normal'}
I am on the latest version of Selenium (3.141) and ChromeDriver (2.29.461585)
Upvotes: 0
Views: 13853
Reputation: 19154
you need to remove /Default/
because its not valid directory for --user-data-dir
it is for --profile-directory
options.add_argument('--profile-directory=Default')
# or
options.add_argument('--profile-directory=other_profile')
Upvotes: 10