0

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)

JeffC
  • 22,180
  • 5
  • 32
  • 55
etayluz
  • 15,920
  • 23
  • 106
  • 151
  • 1
    Yelling at us isn't doing you any favors. – user2357112 Dec 03 '18 at 17:52
  • Not trying to yell - just trying to get some attention to this question so it can be properly answered - it's not going to get answered if it's closed – etayluz Dec 03 '18 at 17:53
  • You appear to have placed two hyphens in front of `user-data-dir`. These hyphens do not appear in the online examples. – user2357112 Dec 03 '18 at 17:55
  • Thanks for taking a stab. I have removed the two hyphens and it doesn't work either. Please reproduce and resolve locally – etayluz Dec 03 '18 at 17:57
  • You're also expecting `~` to be tilde-expanded. This seems unlikely; shell command line processing probably doesn't happen. – user2357112 Dec 03 '18 at 18:00
  • I've also tried playing with this to no avail. Please reproduce and resolve locally to confirm your answers. – etayluz Dec 03 '18 at 18:01
  • 1
    If you want to demonstrate that your question is not a dup, you need to show your work. Show that you addressed the different approaches that are contained in the dups and how it was that they didn't work (error messages, etc). – JeffC Dec 03 '18 at 18:59

1 Answers1

10

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')
ewwink
  • 18,382
  • 2
  • 44
  • 54
  • 1
    I have found that while opening Chrome via Selenium using the Default profile it crashes a lot (race condition?) - so it's best to just create another profile and point to that – etayluz Dec 03 '18 at 19:12