Home > Software design >  How to open Chrome browser in Selenium using the profile you have already logged in with java
How to open Chrome browser in Selenium using the profile you have already logged in with java

Time:10-08

I want to open Chrome browser in Selenium using Java and take a test from a site. But my Chrome browser logs in as a guest. I want to enter as my profile. I am really tired. Please a hero answer me.

ChromeOptions options=new ChromeOptions();

options.addArguments("user-data dir=C:\\Users\\Remi\\AppData\\Local\\Google\\Chrome\\Profile 1");

options.addArguments("profile-directory=Profile 1");

options.addArguments("--disable-extensions");

WebDriver driver =new ChromeDriver(options);

CodePudding user response:

ChromeOptions options=new ChromeOptions();

options.addArguments("user-data dir=C:\\Users\\Remi\\AppData\\Local\\Google\\Chrome\\Profile 1");

options.addArguments("profile-directory=Profile 1");

options.addArguments("--disable-extensions");

WebDriver driver =new ChromeDriver(options);

1126400000076'f843c000-00000076'f843dfff rw-

CodePudding user response:

You missed '-' in 'user-data-dir', it should be:

options.addArguments("--user-data-dir=C:\\Users\\Remi\\AppData\\Local\\Google\\Chrome\\Profile 1");

options.addArguments("--profile-directory=Profile 1");
  • Related