Chrome driver resolution issue in headless mode

61 views
Skip to first unread message

Pritam Ahire

unread,
Jul 16, 2025, 7:16:03 AMJul 16
to ChromeDriver Users
I'm running chrome driver in headless mode and when seeing screenshots then i'm able to see screenshots in tablet view i mean not general desktop resolution why it is happening with latest chromedrivers ? any solution on this ?  I'm using below code to resizing but not working 

public static ChromeOptions MaxScreen() {
try{
    ChromeOptions options = new ChromeOptions();
    options.addArguments("headless=new");
    options.addArguments("window-size=1920,1080");
    options.addArguments("--disable-notifications");
    options.addArguments("--disable-extensions");
    options.addArguments("disable-infobars");
    options.addArguments("force-device-scale-factor=0.90");
    options.addArguments("high-dpi-support=0.75");
    //
    System.out.println("Screen Maximized");

   //options.addArguments("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
    // Prevent detection by WebDriver
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.notifications", 2);
    options.setExperimentalOption("prefs", prefs);
System.out.println("User Action Showed");
    return options;
}
catch (Exception e1) {
        ExitFlag = false;
        TestStepStatus = "FAIL";
        return null;
    }
}
Message has been deleted

Pritam Ahire

unread,
Jul 16, 2025, 10:33:03 AMJul 16
to ChromeDriver Users
My Chrome version is 138 and same version of chromedriver 
Reply all
Reply to author
Forward
0 new messages