selenium加载chrome配置文件java

selenium加载chrome配置文件java,java,selenium,profile,Java,Selenium,Profile,我尝试用selenium加载chrome配置文件。但是,每当我上传配置文件时,都会出现一个错误: 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\\

我尝试用selenium加载chrome配置文件。但是,每当我上传配置文件时,都会出现一个错误:

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=新的ChromeDriverService.Builder()
.usingDriverExecutable(新文件(“C:\\Driver\\chromedriver.exe”)).usingAnyFreePort().build();
ChromeOptions chOption=新的ChromeOptions();
chOption.addArguments(“--user data dir=“+chromeProfile”);
addArguments(“--profile directory=profile 33”);
addArguments(“--start maximized”);
ChromeDriver驱动器=新的ChromeDriver(chSvc,chOption);
驱动程序。获取(“https://google.com");

不能使用相同的
用户数据目录运行ChromeDriver的多个实例。您可以做的是每次创建ChromeDriver实例时,创建一个临时目录,然后在ChromeOptions
chOption.addArguments(“--user data dir=“+tempDir”)中设置它