in conftest.py [0:0]
def _screenshot_whole_screen(filename: str, driver: Firefox, opt_ci: bool):
if not filename.endswith(".png"):
filename = filename + ".png"
artifacts_loc = ""
if opt_ci:
artifacts_loc = "artifacts"
fullpath = os.path.join(artifacts_loc, filename)
screenshot = None
if platform.system() == "Darwin":
screenshot = ImageGrab.grab()
screenshot.save(fullpath)
# compress the image (OSX generates large screenshots)
image = Image.open(fullpath)
width, height = image.size
new_size = (width // 2, height // 2)
resized_image = image.resize(new_size)
resized_image.save(fullpath, optimize=True, quality=50)
elif platform.system() == "Linux":
check_output(["gnome-screenshot", f"--file={fullpath}"])
else:
screenshot = ImageGrab.grab()
screenshot.save(fullpath)
return fullpath