I am trying to get Selenium to open Chrome just as if I was opening it myself, i.e. I should be logged into my accounts like Facebook.
I have the following code:
def startChrome():
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=/Users/alexiseggermont/Library/Application Support/Google/Chrome/Default/")
driver = webdriver.Chrome(chrome_options=options)
driver.set_page_load_timeout(60)
return driver
driver = startChrome()
url = 'https://www.facebook.com'
driver.get(url)
However this gets me to Facebook without being logged in. I have checked chrome://version
and the profile URL is in fact correct. What am I doing wrong?
Using Python 3, Chrome Version 63.0.3239.84, MacOS High Sierra
Remove the Default/
from the end of your path
options.add_argument("user-data-dir=/Users/alexiseggermont/Library/Application Support/Google/Chrome/")
On a PC, it would typically be something like:
options.add_argument('user-data-dir=C:/Users/{USERNAME}/AppData/Local/Google/Chrome/User Data')
You'll need to check you've got compatible versions of chromedriver and chrome - the easiest way to do that, is to check that both are up to date.
If it crashes immediately on opening, check the chromedriver help page. Maybe try disabling all extensions, to see if that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With