硒 python fullscreen_window

selenium python fullscreen_window

我想放满 window,但它只剩下 800x600

def driver(request):
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument('--headless')

try:
    web_driver = webdriver.Chrome(chrome_options=options)
    yield web_driver
    web_driver.close()
except Exception as e:
    pytest.skip(e)

我正在用 selenium 做测试,但是 window 非常差。求助,你怎么能把最大值 window.

可以通过设置window尺寸来设置:

web_driver = webdriver.Chrome(chrome_options=options)
# Resize the window to the screen width/height
web_driver.set_window_size(1024, 720)