e2e: show browser logs to debug CI issues

This commit is contained in:
Jens Langhammer 2020-06-26 15:06:46 +02:00
parent c07bd6e733
commit cc7e4ad0e2
2 changed files with 9 additions and 0 deletions

View File

@ -16,6 +16,7 @@ from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from structlog import get_logger
from passbook.core.models import User
@ -48,6 +49,7 @@ class SeleniumTestCase(StaticLiveServerTestCase):
self.driver.implicitly_wait(5)
self.wait = WebDriverWait(self.driver, 60)
self.apply_default_data()
self.logger = get_logger()
def _get_driver(self) -> WebDriver:
return webdriver.Remote(
@ -57,6 +59,10 @@ class SeleniumTestCase(StaticLiveServerTestCase):
def tearDown(self):
self.driver.save_screenshot(f"out/{self.__class__.__name__}_{time()}.png")
for line in self.driver.get_log("browser"):
self.logger.warning(
line["message"], source=line["source"], level=line["level"]
)
self.driver.quit()
super().tearDown()

View File

@ -50,6 +50,9 @@ const convertToSlug = (text) => {
document.querySelectorAll("input[name=name]").forEach((input) => {
input.addEventListener("input", (e) => {
const form = e.target.closest("form");
if (form === null) {
return;
}
const slugField = form.querySelector("input[name=slug]");
slugField.value = convertToSlug(e.target.value);
});