selenium 使 Chrome 默认最大化打开

通过设置 chrome_options 参数达到默认最大化的效果,示例代码:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('start-maximized')
driver=webdriver.Chrome(chrome_options=chrome_options)

或者:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('start-maximized')
driver=webdriver.Chrome(chrome_options=options)