Expectations
flaui.core.expectations.expect(element, timeout=DEFAULT_TIMEOUT_MS, interval=DEFAULT_INTERVAL_MS)
Create a fluent, auto-waiting assertion for element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
'AutomationElement'
|
The element to assert on. |
required |
timeout
|
int
|
Default time to wait for each expectation, in milliseconds. |
DEFAULT_TIMEOUT_MS
|
interval
|
int
|
Polling interval, in milliseconds. |
DEFAULT_INTERVAL_MS
|
Returns:
| Type | Description |
|---|---|
ElementAssertions
|
An :class: |
Source code in flaui/core/expectations.py
flaui.core.expectations.ElementAssertions(element, timeout=DEFAULT_TIMEOUT_MS, interval=DEFAULT_INTERVAL_MS, is_negated=False)
Fluent expectation builder for a single :class:AutomationElement.
Each to_* matcher polls until the condition holds (or, after :attr:not_, until it no longer
holds) and raises :class:AssertionError on timeout. Create instances via :func:expect.
Initialise the assertion wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
'AutomationElement'
|
The element under assertion. |
required |
timeout
|
int
|
Maximum time to wait for the expectation, in milliseconds. |
DEFAULT_TIMEOUT_MS
|
interval
|
int
|
Polling interval, in milliseconds. |
DEFAULT_INTERVAL_MS
|
is_negated
|
bool
|
Whether matchers should assert the negated condition. |
False
|
Source code in flaui/core/expectations.py
not_
property
Return a negated view of these assertions.
Returns:
| Type | Description |
|---|---|
'ElementAssertions'
|
A new :class: |
to_be_checked(timeout=None)
Assert the element's is_checked state is truthy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |
Source code in flaui/core/expectations.py
to_be_enabled(timeout=None)
Assert the element is enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |
Source code in flaui/core/expectations.py
to_be_offscreen(timeout=None)
Assert the element is off-screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |
Source code in flaui/core/expectations.py
to_be_visible(timeout=None)
Assert the element is available and on-screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |
Source code in flaui/core/expectations.py
to_have_name(expected, timeout=None)
Assert the element's name equals expected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected
|
str
|
The expected name value. |
required |
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |
Source code in flaui/core/expectations.py
to_have_text(expected, timeout=None)
Assert the element's text equals expected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected
|
str
|
The expected text value. |
required |
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |
Source code in flaui/core/expectations.py
to_have_value(expected, timeout=None)
Assert the element's value equals expected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected
|
Any
|
The expected value. |
required |
timeout
|
int | None
|
Optional per-call timeout override, in milliseconds. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the expectation is not met within the timeout. |