The image size obtained by python+selenium get_screenshot_as_png method is larger than expected.

after setting the band size of the browser (800600), using the screenshot method, the picture obtained is actually larger than the browser itself.
ask me, what went wrong? How to deal with

from io import BytesIO
from PIL import Image
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

browser = webdriver.Chrome()
browser.set_window_size(800, 600)
wait = WebDriverWait(browser, 20)
browser.get("https://www.baidu.com/")
screenshot = browser.get_screenshot_as_png()
screenshot = Image.open(BytesIO(screenshot))
browser.get_screenshot_as_file("test.png")
print("size:", browser.get_window_size())
print("size:", screenshot.size)
browser.close()

browser size: {"width": 800," height": 600}
full picture size: (1179699)

update:
has been tested, and the screenshot of the whole image is correct only when using its headless mode.

=
Chrome 67.0.3396.99
selenium 3.13
python 3.6 win10 3.7
win10
the screenshot is always too large


maybe it's your software version. I use the latest version of selenium, python 3, and the output results of chrome, are as expected, as follows

size: {'width': 800, 'height': 600}
size: (800, 491)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30aea-2bd40.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30aea-2bd40.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?