Skip to content

#

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 #

Bases: Match[Collection]

ignore_case: Condition[Collection] property #

_ElementDescriptor #

Bases: Condition[Element]

value(expected) #

value_containing(expected) #

values(*expected) #

values_containing(*expected) #

_EntityHasSomethingSupportingIgnoreCase #

Bases: Match[E]

ignore_case: Condition[E] property #

_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

_globs = () instance-attribute #

where(**kwargs) #

Just a placeholder. This attribute is not supported for this condition

_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

_process_patterns = _process_patterns instance-attribute #

ignore_case: Condition[Collection] property #

not_ property #

where_flags(flags) #

_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

with_wildcards property #

where_wildcards(zero_or_more_chars=None, exactly_one_char=None) #

js #

_active_element: Condition[Element] = Match('has focus', by=lambda element: element.locate() == element.config.driver.execute_script('return document.activeElement')) class-attribute instance-attribute #

size #

Bases: Match[Union[Collection, Browser, Element]]

_less_than: Condition[Collection] property #

_more_than: Condition[Collection] property #

or_less: Condition[Collection] property #

or_more: Condition[Collection] property #

tabs_number #

Bases: Match[Browser]

_less_than: Condition[Browser] property #

_more_than: Condition[Browser] property #

or_less: Condition[Browser] property #

or_more: Condition[Browser] property #

text_pattern #

Bases: Condition[Element]

ignore_case property #

where_flags(flags) #

attribute(name, _inverted=False) #

browser_has_js_returned(expected, script, *args) #

css_class(name, _inverted=False) #

css_property(name, _inverted=False) #

exact_text(expected, _ignore_case=False, _inverted=False) #

exact_texts(*expected, _ignore_case=False, _inverted=False) #

native_property(name, _inverted=False) #

script_returned(expected, script, *args) #

size_greater_than(expected, _inverted=False) #

size_greater_than_or_equal(expected, _inverted=False) #

size_less_than(expected, _inverted=False) #

size_less_than_or_equal(expected, _inverted=False) #

tabs_number_greater_than(expected, _inverted=False) #

tabs_number_greater_than_or_equal(expected, _inverted=False) #

tabs_number_less_than(expected, _inverted=False) #

tabs_number_less_than_or_equal(expected, _inverted=False) #

tag(expected, _name='has tag', _by=predicate.equals) #

tag_containing(expected) #

text_containing(expected, _ignore_case=False, _inverted=False) #

texts(*expected, _ignore_case=False, _inverted=False) #

title(expected, _name='has title', _by=predicate.equals, _inverted=False) #

title_containing(expected, _inverted=False) #

url(expected, _name='has url', _by=predicate.equals, _inverted=False) #

url_containing(expected, _inverted=False) #

value(expected, _inverted=False) #

value_containing(expected, _inverted=False) #

values(*expected, _inverted=False) #

values_containing(*expected, _inverted=False) #