0

I use Selenium WebDriver in a WhatsApp Automation and I try to use headless mode with session saved in Chrome, but it doesn't work.

The DriverFactory:

System.setProperty("webdriver.chrome.driver", "C:\\Users\\4P\\Documents\\DRIVER SELENIUM\\chromedriver.exe");
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("--no-sandbox");
        chromeOptions.addArguments("--headless");     
        chromeOptions.addArguments("--disable-gpu");
        chromeOptions.addArguments("--window-size=1920,1080");
        chromeOptions.addArguments("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36 OPR/60.0.3255.170");
        chromeOptions.addArguments("--user-data-dir=C:\\Users\\4P\\AppData\\Local\\Google\\Chrome\\User Data");
        chromeOptions.addArguments("--remote-debugging-port=9222");
        chromeOptions.addArguments("--profile-directory=Profile 1");
        chromeOptions.setBinary("C:\\Users\\4P\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
        this.driver = new _ChromeDriver(chromeOptions);
        this.driver.manage().window();
        this.js = (JavascriptExecutor) driver;  

My chrome version is 94.0.4606.61.

With I remove the headless mode, I can get the session with no problem.

In another PC, I had success with another configuration, but I don't have access anymore to it.

Can anyone help me?

tquadrat
  • 3,033
  • 1
  • 16
  • 29

0 Answers0