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. :)