In headless mode, the browser window is not open, so driver.maximize_window() cannot find the target or open it. Instead, run in headless mode, specifying the browser window size.

__options = Options() __options.add_argument('--headless') Add_argument ('--window-size=1920x945')# driver = webdriver.Chrome(chrome_options = __options)Copy the code

Also, how do you know the maximum size of your browser?

We can open the console through the JS method, F12

document.documentElement.clientHeight;

document.documentElement.clientWidth;