0

okay so here is my code:

import schedule
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys


options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=C:/Users/soham/AppData/Local/Google/Chrome/User Data")
options.add_argument('--profile-directory=Profile 2')

driver = webdriver.Chrome( executable_path="C:\Program Files (x86)\chromedriver.exe", options=options)


driver.get("google.com")

it gives this error:

C:\Users\soham\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/soham/PycharmProjects/pythonProject/main.py
Traceback (most recent call last):
  File "C:\Users\soham\PycharmProjects\pythonProject\main.py", line 12, in <module>
    driver = webdriver.Chrome( executable_path="C:\Program Files (x86)\chromedriver.exe", options=options)
  File "C:\Users\soham\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\soham\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\soham\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\soham\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\soham\PycharmProjects\pythonProject\venv\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

okay so sorry if you're reading this cause i'm only writing this part cause it was saying its most code and told me to write something soo yeah....HELP.

Md. Fazlul Hoque
  • 15,806
  • 5
  • 12
  • 32
  • Would this help? https://stackoverflow.com/a/60048564/4237080 – brienna Aug 15 '21 at 17:26
  • thanks @brienna but ngl that was too detailed for me to understand im just some 15 y/o trying to automate my school's website – Soham Ahire Aug 15 '21 at 18:08
  • @SohamAhire, welcome to programming, I hope your curiosity rewards you and you build great things. The short of it is that your user profile is already in use, probably by another browser on your computer. They can only be used on one browser at a time, so you need to kill that browser process to free up your profile. – TomM Aug 15 '21 at 21:32
  • @TomM actually I'm using another chrome profile so it's isolated? idk. but if i don't use a chrome profile it works just fine – Soham Ahire Aug 16 '21 at 04:07
  • I miswrote, it is a previously used user data directory, the other option you pass. It is the same issue, but with a different resource. This is laid out in simpler language in the last line of the error message: ```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``` – TomM Aug 16 '21 at 21:03

0 Answers0