0

I have been trying to solve this problem for some time.

from selenium import webdriver

driver = webdriver.Chrome(executable_path= r'./chromedriver.exe')

x= driver.get ("https://www.google.com/")

After execution a tab opens with url: "data"

Return this to me:

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

So far it seems like a duplicate question, but it isn't. Searching for solutions, I found two that didn't work:

1- The first solution I tested is to use the default profile to access the website.

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

options = webdriver.ChromeOptions()
options.add_argument(r'--user-data-dir=C:\Users\Simone\AppData\Local\Google\Chrome\User Data\Profile 3')
options.add_argument(r'--profile-directory=Profile 3')

driver = webdriver.Chrome(executable_path=r'.\chromedriver.exe', chrome_options=options)
driver.get("https://www.google.com/")

After running the code, it actually opens a new window, but it doesn't access the website.

Returns me the same error.

2 - The second solution tested was to use a test profile to access the website.

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

options = Options()
options.add_argument(r"--user-data-dir=C:\Users\Simone\AppData\Local\Google\Chrome\User Data\Profile 2")
options.add_argument(r'--profile-directory=Profile 2')

driver = webdriver.Chrome(executable_path=r'.\chromedriver.exe', chrome_options=options)
driver.get("https://www.google.com/")

After executing the code, a new window opens with the test profile, but it doesn't work.

Returns me the same error:

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 would be very grateful if you could help me, I'm just learning python. Thanks in advance. :)

1 Answers1

0

try the below code and see if it helps as i dont see an issue when i am trying from my side

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

s=Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s)

x= driver.get ("https://www.google.com/")
Rohit
  • 376
  • 3
  • 9
  • I tried to run the code I got the answer: "webdriver_manager.chrome NameError: name 'webdriver_manager' is not defined" I performed the procedure (https://stackoverflow.com/questions/63421086/modulenotfounderror-no-module-named-webdriver-manager-error-even-after-instal), but it didn't work – Pablo Domingues Sep 30 '21 at 00:55