Example #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))
Example #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))
Example #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),
     )
Example #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),
     )
Example #5
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))
Example #6
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))