I am trying to save a canvas element as a png image. This is my code right now but, unfortunately, it does not work:
import time
from selenium import webdriver
# From PIL import Imag.
driver = webdriver.Firefox()
driver.get('http://www.agar.io')
driver.maximize_window()
driver.find_element_by_id('freeCoins').click()
time.sleep(2)
# The part below does not seem to work properly.
driver.execute_script('function download_image(){var canvas = document.getElementByTagName("canvas");canvas.toBlob(function(blob) {saveAs(blob, "../images/output.png");}, "image/png");};')
I would like to see the solution in Python. I would also like to see a solution that does not require cropping at the end of the screenshot.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…