I am learning Selenium. I started with a small project. I am trying to open a link in customized profile's Chrome. But it failed and show the message below:
InvalidArgumentException: invalid argument: user data directory is already in use,...
I tried many ways but it was not success.
Technology I use: Java, Selenium, ChromeDriver
The links I've already tried:
How to open a Chrome Profile through --user-data-dir argument of Selenium
Selenium ChromeDriver: unable to set user-data-dir
String path = "D:\\pathtoexe\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", path);
ChromeOptions options = new ChromeOptions();
options.addArguments("window-size=1024,768");
options.addArguments("user-data-dir=C:\\Users\\UserName\\AppData\\Local\\Google\\Chrome\\User Data");
options.addArguments("profile-directory=Profile 2");
WebDriver driver = new ChromeDriver(options);
driver.get("link_page");
Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442}) on port 43394 Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: 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