'selenium user profile in headless mode, chrome browser
Situation: i'm running chrome in headless mode (see arguments in section part of code), when i connect to page (let say i sign into the page before i run my app that's using selenium) i'm already login to page (because it's using existing profile and i login to page before i started my app) that's on first computer, correct PROFILE is used.
On second computer i'm running Chrome with same settings (same as on computer one) and when i go to the same page as on computer one i'm NOT login to the page (because the profile with existing session is not used)...
If i remove the --headless option everything works... however i want to running it in HEADLESSS mode with current profile used by chrome.
- Driver: Chrome driver version 101
- Java version: 15
- Browser: Google Chrome (version 101.0.4951.64)
- Operating system: both computers have Windows 10
Part of code:
String userP=getChromeUserProfilePath();
options.addArguments(String.format("--user-data-dir=%s",userP));
if(getChromeUserProfileName()!=null){
options.addArguments(String.format("--profile-directory=%s",getChromeUserProfileName()));
}
options.addArguments("--headless",
"--disable-gpu",
"--window-size=1920,1200",
"--ignore-certificate-errors",
"--disable-extensions",
"--no-sandbox",
"--disable-dev-shm-usage");
ChromeDriver webDriver = new ChromeDriver(options);
Questions:
Where's the catch ? How do i make it work for second computer?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|