testudos.api.images
testudos.api.images
High-level image helpers: capture and compare screenshots from the AUT.
Functions here wrap the backend captureScreen / captureItem RPC actions and provide helpers for saving and comparing screenshots.
capture_screen
def capture_screen() -> CapturedImageCapture a screenshot of the entire QML application window.
Returns:
CapturedImage with the captured screenshot.
Raises:
TestudosError- If capture fails or returns a null image.
capture_item
def capture_item(target: str | QtObjectProxy) -> CapturedImageCapture a screenshot of a specific QML item.
Arguments:
target- Object identifier (name or address string) or QtObjectProxy.
Returns:
CapturedImage with the captured screenshot.
Raises:
TestudosError- If capture fails or returns a null image.
save_image
def save_image(image: CapturedImage, path: str) -> NoneSave a captured image to a PNG file.
Arguments:
image- CapturedImage instance.path- Destination path for the PNG file.
capture_screen_to_file
def capture_screen_to_file(path: str) -> NoneCapture the entire application window and save it to a PNG file.
Arguments:
path- Destination path for the PNG file.
capture_item_to_file
def capture_item_to_file(target: str | QtObjectProxy, path: str) -> NoneCapture a specific QML item and save it to a PNG file.
Arguments:
target- Object identifier (name or address string) or QtObjectProxy.path- Destination path for the PNG file.
compare_captured_to_file
def compare_captured_to_file(image: CapturedImage, baseline_path: str, tolerance: float = 0.0) -> boolCompare a captured image with an existing baseline image file.
Arguments:
image- CapturedImage instance.baseline_path- Path to baseline PNG image.tolerance- Maximum allowed mean pixel difference per channel (0–255). 0.0 means pixel-perfect match.
Returns:
True if images are considered equal within tolerance, otherwise False.
compare_files
def compare_files(path_actual: str, path_baseline: str, tolerance: float = 0.0) -> boolCompare two image files on disk.
Arguments:
path_actual- Path to image produced during test.path_baseline- Path to baseline image.tolerance- Maximum allowed mean pixel difference per channel (0–255). 0.0 means pixel-perfect match.
Returns:
True if images are considered equal within tolerance, otherwise False.