selenium headlesschrome下设置最大窗口模式

headless模式下窗口大小的显示方案解决:

        chrome_options = webdriver.ChromeOptions()   #为驱动加入*面配置

        chrome_options.add_argument('--headless')   #–headless”参数是不用打开图形界面
        chrome_options.add_argument('--no-sandbox')  #“–no - sandbox”参数是让Chrome在root权限下跑
        #chrome_options.add_argument("--window-size=4000,1600")  #专门应对无头浏览器中不能最大化屏幕的方案

chrome_options.add_argument("--window-size=1920,1050")  #专门应对无头浏览器中不能最大化屏幕的方案
chromedriver = webdriver.Chrome(chrome_options=chrome_options)

 快速查看浏览器分辨率网址:https://bestfirms.com/what-is-my-screen-resolution/

参考网址:https://www.cnblogs.com/c-x-a/p/8454868.html