I've got a Pi4 and using the latest Pi OS I'm trying to take a screenshot of a Chromium webpage (weather map) with Selenium while displaying weather forescast program with Pygame and it works perfectly The only issue is that it "sometimes" causes Pygame to toggle out of fullscreen and not go back to fullscreen after saving the image This only happens sometimes and not all the time
I think the problem could be solved by using Chromium headless but I cannot get this to work Anyone able to help?
from selenium import webdriver
from PIL import Image
import pygame
driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver')
url = "https://www.windy.com/screenshot?53.199,-2.000,7,i:pressure"
driver.get(url)
driver.fullscreen_window()
driver.implicitly_wait(10)
driver.save_screenshot('weather.png')
basewidth = 240
img = Image.open('weather.png')
driver.quit()
wpercent = (basewidth / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
img = img.resize((basewidth, hsize), Image.ANTIALIAS)
img.save('/home/pi/images/weather_icons/kia.png')
If I use
driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver') --headless
it says
File "map.py", line 4, in <module>
driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver') --headless
NameError: name 'headless' is not defined
I have Firefox-esr installed as well but could not get this working and as chromium browser is working I'd like to stick with this "if possible"