sprogissd
sprogissd

Reputation: 3075

Selenium with Python: how to increase resolution for full screen screenshot?

Is it possible to increase the resolution of a full screen screenshot using Selenium with Python? I currently take screenshots the following way and the resolution appears to be low:

browser = webdriver.Chrome('C:\Python27\chromedriver.exe')
browser.maximize_window()
browser.get("http://www.google.com")
browser.save_screenshot("savedImage.png")

Upvotes: 4

Views: 2524

Answers (2)

tinyhare
tinyhare

Reputation: 2401

Set system "Scale and layout" to 100%, or add Chrome options:

options = ChromeOptions()
options.add_argument("--force-device-scale-factor=1")
driver = webdriver.Chrome(chrome_options=options)

enter image description here

Upvotes: 0

To take higher-DPI screenshots in Chrome selenium webdriver try using --force-device-scale-factor option as below:

desired_dpi = 2.0
options = ChromeOptions()
options.add_argument(f"--force-device-scale-factor={desired_dpi}")
driver = webdriver.Chrome(chrome_options=options)

Upvotes: 4

Related Questions