huskium package

Subpackages

Submodules

huskium.common module

class huskium.common.Area

Bases: object

All Area attributes store (x, y, width, height). Used in Page and Element to set the area action for swipe_by and flick_by.

FULL: tuple = (0.0, 0.0, 1.0, 1.0)

Full window size.

class huskium.common.Offset

Bases: object

All Offset attributes store (start_x, start_y, end_x, end_y). Used in Page and Element to set the offset action for swipe_by and flick_by.

DOWN: tuple = (0.5, 0.25, 0.5, 0.75)

Swipe down (top to bottom).

LEFT: tuple = (0.75, 0.5, 0.25, 0.5)

Swipe left (right to left).

LOWER_LEFT: tuple = (0.75, 0.25, 0.25, 0.75)

Swipe lower left (upper right to lower left).

LOWER_RIGHT: tuple = (0.25, 0.25, 0.75, 0.75)

Swipe lower right (upper left to lower right).

RIGHT: tuple = (0.25, 0.5, 0.75, 0.5)

Swipe right (left to right).

UP: tuple = (0.5, 0.75, 0.5, 0.25)

Swipe up (bottom to top).

UPPER_LEFT: tuple = (0.75, 0.75, 0.25, 0.25)

Swipe upper left (lower right to upper left).

UPPER_RIGHT: tuple = (0.25, 0.75, 0.75, 0.25)

Swipe upper right (lower left to upper right).

huskium.dynamic module

huskium.dynamic.dynamic(func)

Dynamic element decorator for page objects. Applies to any dynamic elements that return an Element or Elements.

Examples

from huskium import dynamic

@dynamic
def my_element(self, par):
    return Element(By.IOS_PREDICATE, 'name CONTAINS "{par}"')

# You can NOT set the dynamic element without the dynamic decorator,
# as it will not trigger the descriptor. The following is incorrect:
def my_element(self, par):
    return Element(By.IOS_PREDICATE, 'name CONTAINS "{par}"')

huskium.exception module

exception huskium.exception.NoSuchCacheException(message: str = 'No cache available, please relocate the element in except.')

Bases: Exception

Typically used internally in Element. If no cache exists, this exception is raised to trigger element relocation.

huskium.logging module

class huskium.logging.BasePrefixFilter(prefix: str | None = None, islower: bool = True, torecord: bool = False)

Bases: Filter

property islower
property prefix
property record
property torecord
class huskium.logging.FilePrefixFilter(prefix: str | None = None, islower: bool = True, torecord: bool = False)

Bases: BasePrefixFilter

Displays logs of file frame whose names start with the target prefix.

Examples

import logging
from huskium import FilePrefixFilter

# Create a filter object with prefix = 'test'.
filter = FilePrefixFilter('test')

# Set up logging with filter.
logging.getLogger().addFilter(filter)

# All logging will follow the filter logic,
# recording logs from file frames with the prefix 'test'.
logging.info(...)
filter(record)

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class huskium.logging.FuncPrefixFilter(prefix: str | None = None, islower: bool = True, torecord: bool = False)

Bases: BasePrefixFilter

Displays logs of function frame whose names start with the target prefix.

Examples

import logging
from huskium import FuncPrefixFilter

# Create a filter object with prefix = 'test'.
filter = FuncPrefixFilter('test')

# Set up logging with filter.
logging.getLogger().addFilter(filter)

# All logging will follow the filter logic,
# recording logs from function frames with the prefix 'test'.
logging.info(...)
filter(record)

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class huskium.logging.LogConfig

Bases: object

General log configuration.

BASIC_CONFIG = {'datefmt': '%Y-%m-%d %H:%M:%S', 'filemode': 'w', 'filename': './log.log', 'format': '%(asctime)s | %(levelname)s | %(filename)s:%(lineno)d | %(funcName)s | %(message)s', 'level': 10}
DATEFMT = '%Y-%m-%d %H:%M:%S'
FILEMODE = 'w'
FILENAME = './log.log'
FORMAT = '%(asctime)s | %(levelname)s | %(filename)s:%(lineno)d | %(funcName)s | %(message)s'
LEVEL = 10
PREFIX_FILTER = <huskium.logging.PrefixFilter object>

Using PREFIX_FILTER.reset_() to reset the internal debug log config.

class huskium.logging.PageElementLoggerAdapter(logger, instance)

Bases: LoggerAdapter

Mainly used in internal Page and Element(s) debug log adapter.

process(msg, kwargs)

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.

Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.

class huskium.logging.PrefixFilter(prefix: str | None = None, islower: bool = True, isfunc: bool = True, torecord: bool = False)

Bases: BasePrefixFilter

Displays logs of frame whose names start with the target prefix.

Examples

import logging
from huskium import PrefixFilter

# Create a filter object with prefix = 'test'.
filter = PrefixFilter('test')

# Set up logging with filter.
logging.getLogger().addFilter(filter)

# All logging will follow the filter logic,
# recording logs from frames with the prefix 'test'.
logging.info(...)
filter(record)

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

property isfunc
property prefixfilter
reset(prefix: str | None = None, islower: bool = True, isfunc: bool = True, torecord: bool = False)

Reset all filter settings.

reset_isfunc(value: bool)
reset_islower(value: bool)
reset_prefix(value: str | None)
reset_torecord(value: bool)

huskium.types module

huskium.wait module

class huskium.wait.Wait(driver: D, timeout: float, poll_frequency: float = 0.5, ignored_exceptions: Iterable[Type[Exception]] | None = None)

Bases: WebDriverWait

Extended WebDriverWait with customizable timeout and ignored_exceptions.

property ignored_exceptions
property timeout

Module contents