diff --git a/src/dropzone.py b/src/dropzone.py index 3b28a25..06bd95e 100644 --- a/src/dropzone.py +++ b/src/dropzone.py @@ -1,5 +1,6 @@ """Provides an error-handling class and file-upload function to allow interaction with dropzones (from DropzoneJS)""" +import logging import time from dataclasses import dataclass from pathlib import Path @@ -10,6 +11,8 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait +logging.basicConfig(level=logging.WARNING, format="%(asctime)s : %(levelname)s : %(message)s") + class ToastErrorException(BaseException): pass @@ -37,7 +40,9 @@ def check_report_toast_error(self) -> None: toast_message = toast_error_box.find_element(By.CLASS_NAME, "toast-message").text raise ToastErrorException(toast_message) except TimeoutException: - pass + logging.info("No toast message found") + except NoSuchElementException: + logging.info("No toast error or error message found") def check_report_dropzone_upload_error(self) -> None: """Wait for timeout window and, if dropzone error message appears first, raise an exception with the content of the error message""" @@ -48,7 +53,7 @@ def check_report_dropzone_upload_error(self) -> None: dropzone_error_message = dropzone_error_box.find_element(By.TAG_NAME, "span").get_attribute("innerHTML") raise DropzoneException(dropzone_error_message) except TimeoutException: - pass + logging.info("No dropzone error found") def check_report_upload_percentage(self) -> None: """Check if dropzone progress bar is present and, if so, raise an exception with the current progress percentage""" @@ -58,7 +63,7 @@ def check_report_upload_percentage(self) -> None: upload_progress = float(upload_progress_bar_width_filled) / float(upload_progress_bar_width) raise LongUploadException(f"File upload timed out at {upload_progress:.0f}%") except NoSuchElementException: - pass + logging.info("No file progress bars found") def add_file_to_dropzone(driver: webdriver, timeout: float, upload_file: Path) -> None: diff --git a/src/forge_api.py b/src/forge_api.py index 95a1db6..9dcf98e 100644 --- a/src/forge_api.py +++ b/src/forge_api.py @@ -62,7 +62,7 @@ def login(self, driver: webdriver, urls: ForgeURLs) -> None: login_button = WebDriverWait(driver, self.timeout).until(EC.element_to_be_clickable((By.CLASS_NAME, "registerbtn"))) login_button.click() except TimeoutException: - pass + logging.info("No username or password field found, or login button is not clickable.") def open_items_list(self, driver: webdriver, urls: ForgeURLs) -> None: """Open the manage craft page, raising an exception if the item table size selector isn't found.""" diff --git a/src/main.py b/src/main.py index e0e9ee0..8533e38 100644 --- a/src/main.py +++ b/src/main.py @@ -42,7 +42,7 @@ def get_readme_html(new_file: Path) -> str: def get_build_file(file_path: PurePath, env_file: str) -> Path: """Combines PurePath and file name into a Path object, ensure that a file exists there, and returns the Path""" new_file = Path(file_path, env_file) - logging.debug("File upload path determined to be: %s", new_file) + logging.info("File upload path determined to be: %s", new_file) if not new_file.is_file(): raise FileNotFoundError(f"File at {str(new_file)} is not found.") return new_file