コード例 #1
0
def collection_has_texts(*expected: str) -> CollectionCondition:
    def visible_texts(collection: Collection) -> List[str]:
        return [webelement.text for webelement in collection() if webelement.is_displayed()]

    return CollectionCondition.raise_if_not_actual(f'has texts {expected}',
                                                   visible_texts,
                                                   predicate.equals_by_contains_to_list(expected))
コード例 #2
0
def collection_has_size(expected: int,
                        describing_matched_to='has size',
                        compared_by_predicate_to=predicate.equals) -> CollectionCondition:
    def size(collection: Collection) -> int:
        return len(collection())

    return CollectionCondition.raise_if_not_actual(f'{describing_matched_to} {expected}',
                                                   size,
                                                   compared_by_predicate_to(expected))
コード例 #3
0
 def values_containing(self, *expected: str) -> Condition[Collection]:
     return CollectionCondition.raise_if_not_actual(
         f"has attribute '{name}' with values containing '{expected}'",
         attribute_values,
         predicate.equals_by_contains_to_list(expected),
     )
コード例 #4
0
 def values(self, *expected: str) -> Condition[Collection]:
     return CollectionCondition.raise_if_not_actual(
         f"has css property '{name}' with values '{expected}'",
         property_values,
         predicate.equals_to_list(expected),
     )
コード例 #5
0
def element_has_tag_containing(expected: str) -> Condition[Element]:
    return element_has_tag(expected, 'has tag containing', predicate.includes)


def _is_collection_empty(collection: Collection) -> bool:
    warnings.warn(
        'match.collection_is_empty or be.empty is deprecated; '
        'use more explicit and obvious have.size(0) instead',
        DeprecationWarning,
    )
    return len(collection()) == 0


collection_is_empty: Condition[Collection] = CollectionCondition.raise_if_not(
    'is empty', _is_collection_empty
)


def collection_has_size(
    expected: int,
    describing_matched_to='has size',
    compared_by_predicate_to=predicate.equals,
) -> Condition[Collection]:
    def size(collection: Collection) -> int:
        return len(collection())

    return CollectionCondition.raise_if_not_actual(
        f'{describing_matched_to} {expected}',
        size,
        compared_by_predicate_to(expected),
コード例 #6
0
 def values(self, *expected: str) -> CollectionCondition:
     return CollectionCondition.raise_if_not_actual(
         f"has attribute '{name}' with values '{expected}'",
         attribute_values,
         predicate.equals_to_list(expected))
コード例 #7
0
 def values_containing(self, *expected: str) -> CollectionCondition:
     return CollectionCondition.raise_if_not_actual(
         f"has css property '{name}' with values containing '{expected}'",
         property_values,
         predicate.equals_by_contains_to_list(expected))