Skip to content

Verification

The Verifier class provides methods to verify elements, screens, and data integrity during test execution.

optics_framework.api.verifier.Verifier

Provides methods to verify elements, screens, and data integrity.

assert_equality(output, expression, event_name=None)

Compares two values for equality. Both values are resolved from session elements if they are ${variable} references before comparison.

Parameters:

Name Type Description Default
output Any

The actual value or ${variable} reference.

required
expression Any

The expected value or ${variable} reference.

required
event_name Optional[str]

The name of the event associated with the comparison, if any.

None

Returns:

Type Description
bool

True if equal, False otherwise.

assert_presence(elements, timeout_str='30', rule='any', event_name=None, fail=True)

Asserts the presence of elements -- anywhere in the page/DOM, visible or not.

Parameters:

Name Type Description Default
elements str

Comma-separated string of elements to check (Image templates, OCR templates, or XPaths).

required
timeout_str str

The time to wait for the elements in seconds.

'30'
rule str

The rule for verification ("any" or "all").

'any'
event_name Optional[str]

The name of the event associated with the assertion, if any.

None
fail Union[bool, str]

If True, raise on failure; if False, return False instead. A suite writes this as text, and False is read case-insensitively.

True

Returns:

Type Description
bool

True if the rule is satisfied, False otherwise.

assert_visibility(elements, timeout_str='30', rule='any', event_name=None, fail=True)

Asserts that elements are actually rendered/visible on screen right now -- distinct from :meth:assert_presence, which reports found even for elements that exist in the page/DOM but are off-screen (e.g. not yet scrolled into view).

Parameters:

Name Type Description Default
elements str

Comma-separated string of elements to check (Image templates, OCR templates, or XPaths).

required
timeout_str str

The time to wait for the elements to become visible, in seconds.

'30'
rule str

The rule for verification ("any" or "all").

'any'
event_name Optional[str]

The name of the event associated with the assertion, if any.

None
fail Union[bool, str]

If True, raise on failure; if False, return False instead. A suite writes this as text, and False is read case-insensitively.

True

Returns:

Type Description
bool

True if the rule is satisfied, False otherwise.

capture_pagesource(event_name=None)

Captures the page source and timestamp of the current screen.

Parameters:

Name Type Description Default
event_name Optional[str]

The name of the event associated with the page source capture, if any.

None

Returns:

Type Description
dict

Dict with "page_source" and "timestamp" keys.

capture_screenshot(event_name=None)

Captures a screenshot of the current screen.

Parameters:

Name Type Description Default
event_name Optional[str]

The name of the event associated with the screenshot capture, if any.

None

Returns:

Type Description
str

The path to the captured screenshot.

get_interactive_elements(filter_config=None, compact=False)

Retrieves a list of interactive elements on the current screen.

XPath and text fields are converted to one-line, CSV-friendly form (newlines as \n, tabs as \t, etc.) so output can be pasted into elements.csv or similar. On Appium sources, element bounds are returned in the screenshot's pixel space.

Parameters:

Name Type Description Default
filter_config Optional[List[str]]

Optional list of filter types (e.g., ["buttons", "inputs"]).

None
compact bool

When True, return only actionable elements (labels folded in, with an act list) plus standalone visible text (act: []), as {i, label, cls, bounds:[x1,y1,x2,y2], act, rid?}. Implemented by the Appium and Playwright page sources; sources without it return their full list.

False

Returns:

Type Description
list

A list of interactive elements.

get_screen_elements()

Captures a screenshot and retrieves interactive elements for API response.

Bounds are scaled to the returned screenshot's pixel space using a single capture shared between the image and the bounds, so callers can overlay the bounds on the screenshot without any scaling of their own.

Returns:

Type Description
dict

Dict with base64-encoded screenshot and list of elements.

is_element(element, element_state, timeout, event_name=None)

Checks if the specified element is in a given state (e.g., Enabled/Disabled/Visible/Invisible).

Parameters:

Name Type Description Default
element str

The element to be checked (Image template, OCR template, or XPath).

required
element_state str

The state to verify (visible, invisible, enabled, disabled).

required
timeout int

The time to wait for the element in seconds.

required
event_name Optional[str]

The name of the event associated with the check, if any.

None

validate_element(element, timeout='10', rule='all', event_name=None)

Verifies the specified element.

Parameters:

Name Type Description Default
element str

The element to be verified (Image template, OCR template, or XPath).

required
timeout str

The time to wait for verification in seconds.

'10'
rule str

The rule used for verification ("all" or "any").

'all'
event_name Optional[str]

The name of the event associated with the verification, if any.

None

validate_screen(elements, timeout='30', rule='any', event_name=None)

Verifies the specified screen by checking element presence.

Parameters:

Name Type Description Default
elements str

Comma-separated string of elements to verify (Image templates, OCR templates, or XPaths).

required
timeout str

The time to wait for verification in seconds.

'30'
rule str

The rule for verification ("any" or "all").

'any'
event_name Optional[str]

The name of the event associated with the verification, if any.

None