#
This is the latest development version
Some features documented on this page may not yet be available in the published stable version.
_empty: Condition[Callable] = Match('is empty', __size_or_value_or_text, by=lambda actual_desc_and_result: not actual_desc_and_result[1], _describe_actual_result=lambda actual_desc_and_result: f'actual {actual_desc_and_result[0]}: {actual_desc_and_result[1]}')
module-attribute
#
Experimental 4-in-1 "is form or input or element or collection empty" condition, that is an alternative to old and deprecated the empty collection condition.
absent: Condition[Element] = Condition('is absent in DOM', present.not_)
module-attribute
#
Deprecated 'is absent' condition. Use absent_in_dom instead.
absent_in_dom: Condition[Element] = Condition('is absent in DOM', present_in_dom.not_)
module-attribute
#
blank: Condition[Element] = Match('is blank', actual=lambda element: ('value', webelement.get_attribute('value')) if (webelement := element.locate()) and webelement.tag_name == 'input' else ('text', webelement.text), by=lambda actual_desc_and_result: not actual_desc_and_result[1], _describe_actual_result=lambda actual_desc_and_result: f'actual {actual_desc_and_result[0]}: {actual_desc_and_result[1]}')
module-attribute
#
Asserts that element is blank, i.e. has empty value if is an element or empty text otherwise.
Is similar to the experimental 4-in-1 _empty condition, works only for singular elements: if they are a value-based elements (like inputs and textarea) then it checks for empty value, if they are text-based elements then it checks for empty text content.
The _empty
condition works same but if applied to collection
then will assert that it has size 0. And when applied to "form" element,
then will check for all form "value-like" inputs to be empty.
Hence, the blank
condition is more precise, while empty
is more general.
Because of its generality, the empty
condition can be easier to remember,
but can lead to some kind of confusion when applied to both element
and collection in same test.
checked: Condition[Element] = native_property('checked').value(True)
module-attribute
#
clickable: Condition[Element] = visible.and_(enabled)
module-attribute
#
disabled: Condition[Element] = enabled.not_
module-attribute
#
empty: Condition[Collection] = Match('is empty', __is_empty, by=predicate.is_truthy)
module-attribute
#
Deprecated 'is empty' collection condition. Use size(0) instead.
enabled: Condition[Element] = Match('is enabled', by=lambda element: element.locate().is_enabled())
module-attribute
#
existing: Condition[Element] = Match('is present in DOM', by=__deprecated_is_existing, _falsy_exceptions=(AssertionError, NoSuchElementException))
module-attribute
#
Deprecated 'is existing' condition. Use present_in_dom instead.
hidden: Condition[Element] = Condition('is hidden', visible.not_)
module-attribute
#
hidden_in_dom: Condition[Element] = present_in_dom.and_(visible.not_)
module-attribute
#
present: Condition[Element] = Match('is present in DOM', by=lambda element: fp.thread(element, fp.with_warn('be.present is deprecated, use be.present_in_dom instead', DeprecationWarning), lambda element: element.locate() is not None), _falsy_exceptions=(AssertionError, NoSuchElementException))
module-attribute
#
Deprecated 'is present' condition. Use present_in_dom instead.
present_in_dom: Condition[Element] = Match('is present in DOM', actual=lambda element: element.locate(), by=lambda webelement: webelement is not None, _describe_actual_result=lambda webelement: f'actual html element: {webelement.get_attribute('outerHTML')}' if not appium_tools._is_mobile_element(webelement) else str(webelement), _falsy_exceptions=(AssertionError, NoSuchElementException))
module-attribute
#
selected: Condition[Element] = Match('is selected', by=lambda element: element.locate().is_selected())
module-attribute
#
visible: Condition[Element] = Match('is visible', actual=lambda element: element.locate(), by=lambda actual: actual.is_displayed(), _describe_actual_result=lambda actual: f'actual html element: {actual.get_attribute('outerHTML')}' if not appium_tools._is_mobile_element(actual) else str(actual), _falsy_exceptions=(AssertionError, NoSuchElementException))
module-attribute
#
_CollectionHasSomeThingsSupportingIgnoreCase
#
_ElementDescriptor
#
_exact_texts_like
#
Bases: Condition[Collection]
Condition to match visible texts of all elements in a collection with supported list globs for items (item placeholders to include/exclude items from match).
_DEFAULT_GLOBS: Tuple[Tuple[Any, str], ...] = (({...}, _PredefinedGlobPatterns['exactly_one']), ([{...}], _PredefinedGlobPatterns['zero_or_one']), (..., _PredefinedGlobPatterns['one_or_more']), ([...], _PredefinedGlobPatterns['zero_or_more']))
class-attribute
instance-attribute
#
_MATCHING_EMPTY_STRING_MARKER = '‹EMTPY_STRING›'
class-attribute
instance-attribute
#
_MATCHING_SEPARATOR = '‚'
class-attribute
instance-attribute
#
A separator to be used while matching to separate texts of different elements in a collection.
Should be quite unique to not interfere with actual texts characters. Otherwise, will brake the match.
Should be a one character string, because is used in predefined pattern for "exactly one" globbing that might not work correctly if there will be more than one character.
_PredefinedGlobPatterns: Dict[_PredefinedPatternType, str] = dict(exactly_one='[^' + _MATCHING_SEPARATOR + ']+', zero_or_one='[^' + _MATCHING_SEPARATOR + ']*', one_or_more='.+?', zero_or_more='.*?')
class-attribute
instance-attribute
#
_PredefinedPatternType = Literal['zero_or_one', 'exactly_one', 'one_or_more', 'zero_or_more']
class-attribute
instance-attribute
#
_RENDERING_SEPARATOR = ', '
class-attribute
instance-attribute
#
_RENDERING_TRANSLATIONS = (({...}, '{...}'), ([{...}], '[{...}]'), (..., '...'), ([...], '[...])'), ((...), '(...,)'), ([(...)], '[(...,)])'))
class-attribute
instance-attribute
#
_expected = expected
instance-attribute
#
_flags = _flags
instance-attribute
#
_globs = _globs
instance-attribute
#
_inverted = _inverted
instance-attribute
#
_name = _name
instance-attribute
#
_name_prefix = _name_prefix
instance-attribute
#
_process_patterns: Callable[[str], str] = re.escape
instance-attribute
#
ignore_case: Condition[Collection]
property
#
not_
property
#
_name_for(entity=None)
#
where(*, exactly_one=None, zero_or_one=None, one_or_more=None, zero_or_more=None)
#
_text_patterns
#
Bases: _text_patterns_like
Condition to match visible texts of all elements in a collection with supported item placeholders to include/exclude items from match (like _exact_texts_like condition) and with additionally supported wildcards (implicit and explicit) for the corresponding matching of each item text in a collection
_text_patterns_like
#
Bases: _exact_texts_like
Condition to match visible texts of all elements in a collection with supported item placeholders to include/exclude items from match (like _exact_texts_like condition) and with additionally supported wildcards (implicit and explicit) for the corresponding matching of each item text in a collection
_texts_like
#
Bases: _exact_texts_like
Condition to match visible texts of all elements in a collection
with supported item globs (placeholders to include/exclude items from match,
like in _exact_texts_like condition)
and matching each expected item text (that is not an item glob) – "by contains".
Has additional support for classic wildcards via .with_wildcards
method
(* matches any number of any characters including none,
? matches any single character).
_process_patterns = _process_patterns
instance-attribute
#
ignore_case: Self
property
#
not_
property
#
with_regex
property
#
An alias to _text_patterns_like condition : switches to regex matching mode for all items in the expected list