For the time being, a script that just creates a file called "screen.png " on the same level and saves ScreenShot there.
screenshot.py
import os
from selenium import webdriver
# URL & File Name
URL = "https://www.google.com"
FILENAME = os.path.join(os.path.dirname(os.path.abspath(__file__)), "screen.png ")
# Open Web Browser & Resize 720P
driver = webdriver.Firefox()
driver.set_window_size(1280, 720)
driver.get(URL)
# Get Screen Shot
driver.save_screenshot(FILENAME)
# Close Web Browser
driver.quit()
I haven't confirmed the operation. I think it will work. I don't know.
Recommended Posts