from selenium.common import TimeoutException class CustomError(Exception): """Base class for custom exceptions""" def __init__(self, message): super().__init__(message) self.message = message class InvalidInputError(CustomError): """Exception raised for invalid inputs""" def __init__(self, value): super().__init__(f"Invalid input: {value}") self.value = value class DatabaseConnectionError(CustomError): """Exception raised for database connection errors""" def __init__(self, db_url): super().__init__(f"Database connection failed: {db_url}") self.db_url = db_url class NoYamlFile(FileNotFoundError): def __init__(self, yaml_file_path, yaml_file_name): super().__init__( f"Please create YAML file at location={yaml_file_path} with filename={yaml_file_name}" ) self.yaml_file_path = yaml_file_path self.yaml_file_name = yaml_file_name class NoElementFound(Exception): def __init__(self, xpath, timeout): super().__init__( f'Element with "{xpath}" XPATH is not located in {timeout} second. Try re-run the testcase' ) self.xpath = xpath self.timeout = timeout class TitleNotFound(Exception): def __init__(self, title, timeout): super().__init__( f'Web Page with "{title}" title is not loaded in {timeout} second.' ) self.title = title self.timeout = timeout