e2e: only save screenshots in CI

This commit is contained in:
Jens Langhammer 2020-07-12 16:17:04 +02:00
parent 91766a2162
commit 8aa0b72b67
1 changed files with 7 additions and 4 deletions

View File

@ -3,7 +3,7 @@ from functools import lru_cache
from glob import glob from glob import glob
from importlib.util import module_from_spec, spec_from_file_location from importlib.util import module_from_spec, spec_from_file_location
from inspect import getmembers, isfunction from inspect import getmembers, isfunction
from os import makedirs from os import environ, makedirs
from time import time from time import time
from Cryptodome.PublicKey import RSA from Cryptodome.PublicKey import RSA
@ -58,9 +58,12 @@ class SeleniumTestCase(StaticLiveServerTestCase):
) )
def tearDown(self): def tearDown(self):
screenshot_file = f"selenium_screenshots/{self.__class__.__name__}_{time()}.png" if "CI" in environ:
self.driver.save_screenshot(screenshot_file) screenshot_file = (
self.logger.warning("Saved screenshot", file=screenshot_file) f"selenium_screenshots/{self.__class__.__name__}_{time()}.png"
)
self.driver.save_screenshot(screenshot_file)
self.logger.warning("Saved screenshot", file=screenshot_file)
for line in self.driver.get_log("browser"): for line in self.driver.get_log("browser"):
self.logger.warning( self.logger.warning(
line["message"], source=line["source"], level=line["level"] line["message"], source=line["source"], level=line["level"]