from time import sleep from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() #options.add_argument('--headless') options.add_argument("start-maximized") #初始化就最大化 br = webdriver.Chrome(chrome_options=options) br.maximize_window() #第一种加载完成后最大化 url = "https://www.tmall.com" br.get(url) size_Dict = br.get_window_size() # 打印浏览器的宽和高 print("当前浏览器的宽:", size_Dict['width']) print("当前浏览器的高:", size_Dict['height']) # 设置浏览器的大小 br.set_window_size(width=500, height=1500, windowHandle="current")