Answer the question
In order to leave comments, you need to log in
Python: how to get a screenshot of the entire page?
Hello.
Here is my code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(options=chrome_options)
driver.get(URL)
filename = "screenshots/" + filename_prefix + "-" + get_timestamp() + ".png"
print("Saving " + filename)
element = driver.find_element_by_tag_name('body')
element.screenshot(filename)
driver.quit()
element = driver.find_element_by_tag_name('body')
element.screenshot(filename)
driver.get_screenshot_as_file(filename)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question