Error in Python Selenium just for loading a page

Here's my code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument(r'--user-data-dir=C:\Users\Winsome\AppData\Local\Google\Chrome\User Data')
options.add_argument('--profile-directory=Profile 4')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_argument('log-level=3')

driver = webdriver.Chrome(executable_path='chromedriver', options=options)
driver.get("https://github.com")

When I run the code, I get an error:

Traceback (most recent call last): File "app.py", line 10, in driver = webdriver.Chrome(executable_path='chromedriver', options=options) File "C:\Users\Winsome\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "C:\Users\Winsome\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Users\Winsome\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\Winsome\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\Winsome\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

I am sure that I have no chrome windows open, but I don't know why I'm getting the error :( Can anyone help?



Read more here: https://stackoverflow.com/questions/68468536/error-in-python-selenium-just-for-loading-a-page

Content Attribution

This content was originally published by Abhirajshri Winsome at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: