0

I tried loading the chrome profile with selenium. However, whenever I upload the profile, I get an error:

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. 
String chromeProfile = "C:\\Users\\ad\\AppData\\Local\\Google\\Chrome\\User Data"; ChromeDriverService chSvc = new ChromeDriverService.Builder() .usingDriverExecutable(new File("C:\\Driver\\chromedriver.exe")).usingAnyFreePort().build(); ChromeOptions chOption = new ChromeOptions(); chOption.addArguments("--user-data-dir=" + chromeProfile); chOption.addArguments("--profile-directory=Profile 33"); chOption.addArguments("--start-maximized"); ChromeDriver driver = new ChromeDriver(chSvc, chOption); driver.get("https://google.com"); 

enter image description here

    1 Answer 1

    1

    You cannot run multiple instance of ChromeDriver with the same user-data-dir. What you can do is every time you create a ChromeDriver instance, create a temp directory then set it in ChromeOptions chOption.addArguments("--user-data-dir=" + tempDir);

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.