From 8bb3cfe70e61ad2c1add743a783fe43ca0e06d29 Mon Sep 17 00:00:00 2001 From: Aleksandr Kotlyar Date: Sat, 30 Oct 2021 10:11:09 +0300 Subject: [PATCH] [#393] python 3.10 - fix type hints for Callable objects. --- .github/workflows/tests.yml | 8 ++- selene/core/conditions.py | 6 +- selene/core/entity.py | 18 +++--- selene/core/match.py | 94 +++++++++++++++---------------- selene/support/conditions/have.py | 52 ++++++++--------- selene/support/conditions/not_.py | 94 +++++++++++++++---------------- 6 files changed, 138 insertions(+), 134 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a488bc1a..07aa60f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,10 @@ jobs: test: name: Test selene runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + python-version: [ '3.7', '3.10' ] env: DISPLAY: ":99" steps: @@ -22,10 +26,10 @@ jobs: poetry.lock tests.yml - - name: Set up Python + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: '3.7' + python-version: ${{ matrix.python-version }} if: env.GIT_DIFF # can be packaged as Docker-image diff --git a/selene/core/conditions.py b/selene/core/conditions.py index aa80402a..0575ccd7 100644 --- a/selene/core/conditions.py +++ b/selene/core/conditions.py @@ -23,13 +23,13 @@ from selene.core.entity import Browser, Element, Collection -class ElementCondition(Condition[Element]): +class ElementCondition(Condition[[Element], None]): pass -class CollectionCondition(Condition[Collection]): +class CollectionCondition(Condition[[Collection], None]): pass -class BrowserCondition(Condition[Browser]): +class BrowserCondition(Condition[[Browser], None]): pass diff --git a/selene/core/entity.py b/selene/core/entity.py index e72d6b1a..214465d3 100644 --- a/selene/core/entity.py +++ b/selene/core/entity.py @@ -526,7 +526,7 @@ def fn(element: Element): # we need this method here in order to make autocompletion work... # unfortunately the "base class" version is not enough def should( - self, condition: Condition[Element], timeout: int = None + self, condition: Condition[[Element], None], timeout: int = None ) -> Element: if timeout: warnings.warn( @@ -1014,7 +1014,7 @@ def to(self, stop: int) -> Collection: return self[:stop] def filtered_by( - self, condition: Union[Condition[Element], Callable[[E], None]] + self, condition: Union[Condition[[Element], None], Callable[[E], None]] ) -> Collection: condition = ( condition @@ -1037,7 +1037,7 @@ def filtered_by( def filtered_by_their( self, selector_or_callable: Union[str, tuple, Callable[[Element], Element]], - condition: Condition[Element], + condition: Condition[[Element], None], ) -> Collection: """ :param selector_or_callable: @@ -1100,7 +1100,7 @@ def find_in(parent: Element): return self.filtered_by(lambda it: condition(find_in(it))) def element_by( - self, condition: Union[Condition[Element], Callable[[E], None]] + self, condition: Union[Condition[[Element], None], Callable[[E], None]] ) -> Element: # todo: In the implementation below... # We use condition in context of "matching", i.e. as a predicate... @@ -1162,7 +1162,7 @@ def find() -> WebElement: def element_by_its( self, selector_or_callable: Union[str, tuple, Callable[[Element], Element]], - condition: Condition[Element], + condition: Condition[[Element], None], ) -> Element: """ :param selector_or_callable: @@ -1318,7 +1318,7 @@ def collected( def should( self, - condition: Union[Condition[Collection], Condition[Element]], + condition: Union[Condition[[Collection], None], Condition[[Element], None]], timeout: int = None, ) -> Collection: if isinstance(condition, ElementCondition): @@ -1361,21 +1361,21 @@ def caching(self) -> Collection: ) return self.cached - def all_by(self, condition: Condition[Element]) -> Collection: + def all_by(self, condition: Condition[[Element], None]) -> Collection: warnings.warn( "deprecated; use `filtered_by` instead: browser.all('.foo').filtered_by(be.enabled)", DeprecationWarning, ) return self.filtered_by(condition) - def filter_by(self, condition: Condition[Element]) -> Collection: + def filter_by(self, condition: Condition[[Element], None]) -> Collection: warnings.warn( "deprecated; use `filtered_by` instead: browser.all('.foo').filtered_by(be.enabled)", DeprecationWarning, ) return self.filtered_by(condition) - def find_by(self, condition: Condition[Element]) -> Element: + def find_by(self, condition: Condition[[Element], None]) -> Element: warnings.warn( "deprecated; use `element_by` instead: browser.all('.foo').element_by(be.enabled)", DeprecationWarning, diff --git a/selene/core/match.py b/selene/core/match.py index 2a28828e..72484945 100644 --- a/selene/core/match.py +++ b/selene/core/match.py @@ -33,35 +33,35 @@ from selene.core.entity import Collection, Element, Browser # todo: consider moving to selene.match.element.is_visible, etc... -element_is_visible: Condition[Element] = ElementCondition.raise_if_not( +element_is_visible: Condition[[Element], None] = ElementCondition.raise_if_not( 'is visible', lambda element: element().is_displayed() ) -element_is_hidden: Condition[Element] = ElementCondition.as_not( +element_is_hidden: Condition[[Element], None] = ElementCondition.as_not( element_is_visible, 'is hidden' ) -element_is_enabled: Condition[Element] = ElementCondition.raise_if_not( +element_is_enabled: Condition[[Element], None] = ElementCondition.raise_if_not( 'is enabled', lambda element: element().is_enabled() ) -element_is_disabled: Condition[Element] = ElementCondition.as_not( +element_is_disabled: Condition[[Element], None] = ElementCondition.as_not( element_is_enabled ) -element_is_clickable: Condition[Element] = element_is_visible.and_( +element_is_clickable: Condition[[Element], None] = element_is_visible.and_( element_is_enabled ) -element_is_present: Condition[Element] = ElementCondition.raise_if_not( +element_is_present: Condition[[Element], None] = ElementCondition.raise_if_not( 'is present in DOM', lambda element: element() is not None ) -element_is_absent: Condition[Element] = ElementCondition.as_not( +element_is_absent: Condition[[Element], None] = ElementCondition.as_not( element_is_present ) -element_is_focused: Condition[Element] = ElementCondition.raise_if_not( +element_is_focused: Condition[[Element], None] = ElementCondition.raise_if_not( 'is focused', # todo: change in the following line to element.execute_script or element.config.driver.execute_script lambda element: element() @@ -73,7 +73,7 @@ def element_has_text( expected: str, describing_matched_to='has text', compared_by_predicate_to=predicate.includes, -) -> Condition[Element]: +) -> Condition[[Element], None]: return ElementCondition.raise_if_not_actual( describing_matched_to + ' ' + expected, query.text, @@ -81,7 +81,7 @@ def element_has_text( ) -def element_has_exact_text(expected: str) -> Condition[Element]: +def element_has_exact_text(expected: str) -> Condition[[Element], None]: return element_has_text(expected, 'has exact text', predicate.equals) @@ -98,28 +98,28 @@ def property_values(collection: Collection) -> List[str]: ) class ConditionWithValues(ElementCondition): - def value(self, expected: str) -> Condition[Element]: + def value(self, expected: str) -> Condition[[Element], None]: return ElementCondition.raise_if_not_actual( f"has js property '{name}' with value '{expected}'", property_value, predicate.equals(expected), ) - def value_containing(self, expected: str) -> Condition[Element]: + def value_containing(self, expected: str) -> Condition[[Element], None]: return ElementCondition.raise_if_not_actual( f"has js property '{name}' with value containing '{expected}'", property_value, predicate.includes(expected), ) - def values(self, *expected: str) -> Condition[Collection]: + def values(self, *expected: str) -> Condition[[Collection], None]: return CollectionCondition.raise_if_not_actual( f"has js property '{name}' with values '{expected}'", property_values, predicate.equals_to_list(expected), ) - def values_containing(self, *expected: str) -> Condition[Collection]: + def values_containing(self, *expected: str) -> Condition[[Collection], None]: return CollectionCondition.raise_if_not_actual( f"has js property '{name}' with values containing '{expected}'", property_values, @@ -145,28 +145,28 @@ def property_values(collection: Collection) -> List[str]: ) class ConditionWithValues(ElementCondition): - def value(self, expected: str) -> Condition[Element]: + def value(self, expected: str) -> Condition[[Element], None]: return ElementCondition.raise_if_not_actual( f"has css property '{name}' with value '{expected}'", property_value, predicate.equals(expected), ) - def value_containing(self, expected: str) -> Condition[Element]: + def value_containing(self, expected: str) -> Condition[[Element], None]: return ElementCondition.raise_if_not_actual( f"has css property '{name}' with value containing '{expected}'", property_value, predicate.includes(expected), ) - def values(self, *expected: str) -> Condition[Collection]: + def values(self, *expected: str) -> Condition[[Collection], None]: return CollectionCondition.raise_if_not_actual( f"has css property '{name}' with values '{expected}'", property_values, predicate.equals_to_list(expected), ) - def values_containing(self, *expected: str) -> Condition[Collection]: + def values_containing(self, *expected: str) -> Condition[[Collection], None]: return CollectionCondition.raise_if_not_actual( f"has css property '{name}' with values containing '{expected}'", property_values, @@ -192,7 +192,7 @@ def attribute_values(collection: Collection) -> List[str]: class ConditionWithValues(ElementCondition): def value( self, expected: str, ignore_case=False - ) -> Condition[Element]: + ) -> Condition[[Element], None]: if ignore_case: warnings.warn( 'ignore_case syntax is experimental and might change in future', @@ -206,7 +206,7 @@ def value( def value_containing( self, expected: str, ignore_case=False - ) -> Condition[Element]: + ) -> Condition[[Element], None]: if ignore_case: warnings.warn( 'ignore_case syntax is experimental and might change in future', @@ -218,14 +218,14 @@ def value_containing( predicate.includes(expected, ignore_case), ) - def values(self, *expected: str) -> Condition[Collection]: + def values(self, *expected: str) -> Condition[[Collection], None]: return CollectionCondition.raise_if_not_actual( f"has attribute '{name}' with values '{expected}'", attribute_values, predicate.equals_to_list(expected), ) - def values_containing(self, *expected: str) -> Condition[Collection]: + def values_containing(self, *expected: str) -> Condition[[Collection], None]: return CollectionCondition.raise_if_not_actual( f"has attribute '{name}' with values containing '{expected}'", attribute_values, @@ -237,20 +237,20 @@ def values_containing(self, *expected: str) -> Condition[Collection]: ) -element_is_selected: Condition[Element] = element_has_attribute( +element_is_selected: Condition[[Element], None] = element_has_attribute( 'elementIsSelected' ) -def element_has_value(expected: str) -> Condition[Element]: +def element_has_value(expected: str) -> Condition[[Element], None]: return element_has_attribute('value').value(expected) -def element_has_value_containing(expected: str) -> Condition[Element]: +def element_has_value_containing(expected: str) -> Condition[[Element], None]: return element_has_attribute('value').value_containing(expected) -def element_has_css_class(expected: str) -> Condition[Element]: +def element_has_css_class(expected: str) -> Condition[[Element], None]: def class_attribute_value(element: Element) -> str: return element().get_attribute('class') @@ -261,7 +261,7 @@ def class_attribute_value(element: Element) -> str: ) -element_is_blank: Condition[Element] = element_has_exact_text('').and_( +element_is_blank: Condition[[Element], None] = element_has_exact_text('').and_( element_has_value('') ) @@ -270,7 +270,7 @@ def element_has_tag( expected: str, describing_matched_to='has tag', compared_by_predicate_to=predicate.equals, -) -> Condition[Element]: +) -> Condition[[Element], None]: return ElementCondition.raise_if_not_actual( f'{describing_matched_to} + {expected}', query.tag, @@ -278,7 +278,7 @@ def element_has_tag( ) -def element_has_tag_containing(expected: str) -> Condition[Element]: +def element_has_tag_containing(expected: str) -> Condition[[Element], None]: return element_has_tag(expected, 'has tag containing', predicate.includes) @@ -291,7 +291,7 @@ def _is_collection_empty(collection: Collection) -> bool: return len(collection()) == 0 -collection_is_empty: Condition[Collection] = CollectionCondition.raise_if_not( +collection_is_empty: Condition[[Collection], None] = CollectionCondition.raise_if_not( 'is empty', _is_collection_empty ) @@ -300,7 +300,7 @@ def collection_has_size( expected: int, describing_matched_to='has size', compared_by_predicate_to=predicate.equals, -) -> Condition[Collection]: +) -> Condition[[Collection], None]: def size(collection: Collection) -> int: return len(collection()) @@ -311,7 +311,7 @@ def size(collection: Collection) -> int: ) -def collection_has_size_greater_than(expected: int) -> Condition[Collection]: +def collection_has_size_greater_than(expected: int) -> Condition[[Collection], None]: return collection_has_size( expected, 'has size greater than', predicate.is_greater_than ) @@ -319,7 +319,7 @@ def collection_has_size_greater_than(expected: int) -> Condition[Collection]: def collection_has_size_greater_than_or_equal( expected: int, -) -> Condition[Collection]: +) -> Condition[[Collection], None]: return collection_has_size( expected, 'has size greater than or equal', @@ -327,7 +327,7 @@ def collection_has_size_greater_than_or_equal( ) -def collection_has_size_less_than(expected: int) -> Condition[Collection]: +def collection_has_size_less_than(expected: int) -> Condition[[Collection], None]: return collection_has_size( expected, 'has size less than', predicate.is_less_than ) @@ -335,7 +335,7 @@ def collection_has_size_less_than(expected: int) -> Condition[Collection]: def collection_has_size_less_than_or_equal( expected: int, -) -> Condition[Collection]: +) -> Condition[[Collection], None]: return collection_has_size( expected, 'has size less than or equal', @@ -344,7 +344,7 @@ def collection_has_size_less_than_or_equal( # todo: make it configurable whether assert only visible texts or ot -def collection_has_texts(*expected: str) -> Condition[Collection]: +def collection_has_texts(*expected: str) -> Condition[[Collection], None]: def visible_texts(collection: Collection) -> List[str]: return [ webelement.text @@ -359,7 +359,7 @@ def visible_texts(collection: Collection) -> List[str]: ) -def collection_has_exact_texts(*expected: str) -> Condition[Collection]: +def collection_has_exact_texts(*expected: str) -> Condition[[Collection], None]: def visible_texts(collection: Collection) -> List[str]: return [ webelement.text @@ -380,7 +380,7 @@ def browser_has_url( expected: str, describing_matched_to='has url', compared_by_predicate_to=predicate.equals, -) -> Condition[Browser]: +) -> Condition[[Browser], []]: def url(browser: Browser) -> str: return browser.driver.current_url @@ -391,7 +391,7 @@ def url(browser: Browser) -> str: ) -def browser_has_url_containing(expected: str) -> Condition[Browser]: +def browser_has_url_containing(expected: str) -> Condition[[Browser], None]: return browser_has_url(expected, 'has url containing', predicate.includes) @@ -399,7 +399,7 @@ def browser_has_title( expected: str, describing_matched_to='has title', compared_by_predicate_to=predicate.equals, -) -> Condition[Browser]: +) -> Condition[[Browser], None]: def title(browser: Browser) -> str: return browser.driver.title @@ -410,7 +410,7 @@ def title(browser: Browser) -> str: ) -def browser_has_title_containing(expected: str) -> Condition[Browser]: +def browser_has_title_containing(expected: str) -> Condition[[Browser], None]: return browser_has_title( expected, 'has title containing', predicate.includes ) @@ -420,7 +420,7 @@ def browser_has_tabs_number( expected: int, describing_matched_to='has tabs number', compared_by_predicate_to=predicate.equals, -) -> Condition[Browser]: +) -> Condition[[Browser], None]: def tabs_number(browser: Browser) -> int: return len(browser.driver.window_handles) @@ -431,7 +431,7 @@ def tabs_number(browser: Browser) -> int: ) -def browser_has_tabs_number_greater_than(expected: int) -> Condition[Browser]: +def browser_has_tabs_number_greater_than(expected: int) -> Condition[[Browser], None]: return browser_has_tabs_number( expected, 'has tabs number greater than', predicate.is_greater_than ) @@ -439,7 +439,7 @@ def browser_has_tabs_number_greater_than(expected: int) -> Condition[Browser]: def browser_has_tabs_number_greater_than_or_equal( expected: int, -) -> Condition[Browser]: +) -> Condition[[Browser], None]: return browser_has_tabs_number( expected, 'has tabs number greater than or equal', @@ -447,7 +447,7 @@ def browser_has_tabs_number_greater_than_or_equal( ) -def browser_has_tabs_number_less_than(expected: int) -> Condition[Browser]: +def browser_has_tabs_number_less_than(expected: int) -> Condition[[Browser], None]: return browser_has_tabs_number( expected, 'has tabs number less than', predicate.is_less_than ) @@ -455,7 +455,7 @@ def browser_has_tabs_number_less_than(expected: int) -> Condition[Browser]: def browser_has_tabs_number_less_than_or_equal( expected: int, -) -> Condition[Browser]: +) -> Condition[[Browser], None]: return browser_has_tabs_number( expected, 'has tabs number less than or equal', @@ -465,7 +465,7 @@ def browser_has_tabs_number_less_than_or_equal( def browser_has_js_returned( expected: Any, script: str, *args -) -> Condition[Browser]: +) -> Condition[[Browser], None]: def script_result(browser: Browser): return browser.driver.execute_script(script, *args) diff --git a/selene/support/conditions/have.py b/selene/support/conditions/have.py index 1372f551..f69141fc 100644 --- a/selene/support/conditions/have.py +++ b/selene/support/conditions/have.py @@ -30,12 +30,12 @@ no = _not_ -def exact_text(value) -> Condition[Element]: +def exact_text(value) -> Condition[[Element], None]: return match.element_has_exact_text(value) # todo: consider accepting int -def text(partial_value) -> Condition[Element]: +def text(partial_value) -> Condition[[Element], None]: return match.element_has_text(partial_value) @@ -73,46 +73,46 @@ def attribute(name: str, value: str = None): return match.element_has_attribute(name) -def value(text) -> Condition[Element]: +def value(text) -> Condition[[Element], None]: return match.element_has_value(text) -def value_containing(partial_text) -> Condition[Element]: +def value_containing(partial_text) -> Condition[[Element], None]: return match.element_has_value_containing(partial_text) -def css_class(name) -> Condition[Element]: +def css_class(name) -> Condition[[Element], None]: return match.element_has_css_class(name) -def tag(name: str) -> Condition[Element]: +def tag(name: str) -> Condition[[Element], None]: return match.element_has_tag(name) -def tag_containing(name: str) -> Condition[Element]: +def tag_containing(name: str) -> Condition[[Element], None]: return match.element_has_tag_containing(name) # *** SeleneCollection conditions *** -def size(number: int) -> Condition[Collection]: +def size(number: int) -> Condition[[Collection], None]: return match.collection_has_size(number) -def size_less_than(number: int) -> Condition[Collection]: +def size_less_than(number: int) -> Condition[[Collection], None]: return match.collection_has_size_less_than(number) -def size_less_than_or_equal(number: int) -> Condition[Collection]: +def size_less_than_or_equal(number: int) -> Condition[[Collection], None]: return match.collection_has_size_less_than_or_equal(number) -def size_greater_than(number: int) -> Condition[Collection]: +def size_greater_than(number: int) -> Condition[[Collection], None]: return match.collection_has_size_greater_than(number) -def size_at_least(number: int) -> Condition[Collection]: +def size_at_least(number: int) -> Condition[[Collection], None]: warnings.warn( 'might be deprecated; use have.size_greater_than_or_equal instead', PendingDeprecationWarning, @@ -120,56 +120,56 @@ def size_at_least(number: int) -> Condition[Collection]: return match.collection_has_size_greater_than_or_equal(number) -def size_greater_than_or_equal(number: int) -> Condition[Collection]: +def size_greater_than_or_equal(number: int) -> Condition[[Collection], None]: return match.collection_has_size_greater_than_or_equal(number) # todo: consider accepting ints -def texts(*partial_values: str) -> Condition[Collection]: +def texts(*partial_values: str) -> Condition[[Collection], None]: return match.collection_has_texts(*partial_values) -def exact_texts(*values: str) -> Condition[Collection]: +def exact_texts(*values: str) -> Condition[[Collection], None]: return match.collection_has_exact_texts(*values) -def url(exact_value: str) -> Condition[Browser]: +def url(exact_value: str) -> Condition[[Browser], None]: return match.browser_has_url(exact_value) -def url_containing(partial_value: str) -> Condition[Browser]: +def url_containing(partial_value: str) -> Condition[[Browser], None]: return match.browser_has_url_containing(partial_value) -def title(exact_value: str) -> Condition[Browser]: +def title(exact_value: str) -> Condition[[Browser], None]: return match.browser_has_title(exact_value) -def title_containing(partial_value: str) -> Condition[Browser]: +def title_containing(partial_value: str) -> Condition[[Browser], None]: return match.browser_has_title_containing(partial_value) -def tabs_number(value: int) -> Condition[Browser]: +def tabs_number(value: int) -> Condition[[Browser], None]: return match.browser_has_tabs_number(value) -def tabs_number_less_than(value: int) -> Condition[Browser]: +def tabs_number_less_than(value: int) -> Condition[[Browser], None]: return match.browser_has_tabs_number_less_than(value) -def tabs_number_less_than_or_equal(value: int) -> Condition[Browser]: +def tabs_number_less_than_or_equal(value: int) -> Condition[[Browser], None]: return match.browser_has_tabs_number_less_than_or_equal(value) -def tabs_number_greater_than(value: int) -> Condition[Browser]: +def tabs_number_greater_than(value: int) -> Condition[[Browser], None]: return match.browser_has_tabs_number_greater_than(value) -def tabs_number_greater_than_or_equal(value: int) -> Condition[Browser]: +def tabs_number_greater_than_or_equal(value: int) -> Condition[[Browser], None]: return match.browser_has_tabs_number_greater_than_or_equal(value) -def js_returned_true(script_to_return_bool: str) -> Condition[Browser]: +def js_returned_true(script_to_return_bool: str) -> Condition[[Browser], None]: warnings.warn( 'might be deprecated; use have.js_returned(True, ...) instead', PendingDeprecationWarning, @@ -177,5 +177,5 @@ def js_returned_true(script_to_return_bool: str) -> Condition[Browser]: return match.browser_has_js_returned(True, script_to_return_bool) -def js_returned(expected: Any, script: str, *args) -> Condition[Browser]: +def js_returned(expected: Any, script: str, *args) -> Condition[[Browser], None]: return match.browser_has_js_returned(expected, script, *args) diff --git a/selene/support/conditions/not_.py b/selene/support/conditions/not_.py index 88bd20f0..24922521 100644 --- a/selene/support/conditions/not_.py +++ b/selene/support/conditions/not_.py @@ -28,32 +28,32 @@ from selene.core.condition import Condition from selene.core.entity import Element, Collection, Browser -visible: Condition[Element] = _match.element_is_visible.not_ -hidden: Condition[Element] = _match.element_is_hidden.not_ +visible: Condition[[Element], None] = _match.element_is_visible.not_ +hidden: Condition[[Element], None] = _match.element_is_hidden.not_ -present: Condition[Element] = _match.element_is_present.not_ -in_dom: Condition[Element] = _match.element_is_present.not_ +present: Condition[[Element], None] = _match.element_is_present.not_ +in_dom: Condition[[Element], None] = _match.element_is_present.not_ # todo: do we need both present and in_dom? # todo: consider deprecating existing -existing: Condition[Element] = _match.element_is_present.not_ +existing: Condition[[Element], None] = _match.element_is_present.not_ -absent: Condition[Element] = _match.element_is_absent.not_ +absent: Condition[[Element], None] = _match.element_is_absent.not_ -enabled: Condition[Element] = _match.element_is_enabled.not_ -disabled: Condition[Element] = _match.element_is_disabled.not_ +enabled: Condition[[Element], None] = _match.element_is_enabled.not_ +disabled: Condition[[Element], None] = _match.element_is_disabled.not_ -blank: Condition[Element] = _match.element_is_blank.not_ +blank: Condition[[Element], None] = _match.element_is_blank.not_ # --- have.* conditions --- # -def exact_text(value) -> Condition[Element]: +def exact_text(value) -> Condition[[Element], None]: return _match.element_has_exact_text(value).not_ # todo: consider accepting int -def text(partial_value) -> Condition[Element]: +def text(partial_value) -> Condition[[Element], None]: return _match.element_has_text(partial_value).not_ @@ -68,18 +68,18 @@ def attribute(name: str, value: str = None): original = _match.element_has_attribute(name) negated = original.not_ - def value(self, expected: str, ignore_case=False) -> Condition[Element]: + def value(self, expected: str, ignore_case=False) -> Condition[[Element], None]: return original.value(expected, ignore_case).not_ def value_containing( self, expected: str, ignore_case=False - ) -> Condition[Element]: + ) -> Condition[[Element], None]: return original.value_containing(expected, ignore_case).not_ - def values(self, *expected: str) -> Condition[Collection]: + def values(self, *expected: str) -> Condition[[Collection], None]: return original.values(*expected).not_ - def values_containing(self, *expected: str) -> Condition[Collection]: + def values_containing(self, *expected: str) -> Condition[[Collection], None]: return original.values_containing(*expected).not_ negated.value = value @@ -101,16 +101,16 @@ def js_property(name: str, value: str = None): original = _match.element_has_js_property(name) negated = original.not_ - def value(self, expected: str) -> Condition[Element]: + def value(self, expected: str) -> Condition[[Element], None]: return original.value(expected).not_ - def value_containing(self, expected: str) -> Condition[Element]: + def value_containing(self, expected: str) -> Condition[[Element], None]: return original.value_containing(expected).not_ - def values(self, *expected: str) -> Condition[Collection]: + def values(self, *expected: str) -> Condition[[Collection], None]: return original.values(*expected).not_ - def values_containing(self, *expected: str) -> Condition[Collection]: + def values_containing(self, *expected: str) -> Condition[[Collection], None]: return original.values_containing(*expected).not_ negated.value = value @@ -132,16 +132,16 @@ def css_property(name: str, value: str = None): original = _match.element_has_css_property(name) negated = original.not_ - def value(self, expected: str) -> Condition[Element]: + def value(self, expected: str) -> Condition[[Element], None]: return original.value(expected).not_ - def value_containing(self, expected: str) -> Condition[Element]: + def value_containing(self, expected: str) -> Condition[[Element], None]: return original.value_containing(expected).not_ - def values(self, *expected: str) -> Condition[Collection]: + def values(self, *expected: str) -> Condition[[Collection], None]: return original.values(*expected).not_ - def values_containing(self, *expected: str) -> Condition[Collection]: + def values_containing(self, *expected: str) -> Condition[[Collection], None]: return original.values_containing(*expected).not_ negated.value = value @@ -152,46 +152,46 @@ def values_containing(self, *expected: str) -> Condition[Collection]: return negated -def value(text) -> Condition[Element]: +def value(text) -> Condition[[Element], None]: return _match.element_has_value(text).not_ -def value_containing(partial_text) -> Condition[Element]: +def value_containing(partial_text) -> Condition[[Element], None]: return _match.element_has_value_containing(partial_text).not_ -def css_class(name) -> Condition[Element]: +def css_class(name) -> Condition[[Element], None]: return _match.element_has_css_class(name).not_ -def tag(name: str) -> Condition[Element]: +def tag(name: str) -> Condition[[Element], None]: return _match.element_has_tag(name).not_ -def tag_containing(name: str) -> Condition[Element]: +def tag_containing(name: str) -> Condition[[Element], None]: return _match.element_has_tag_containing(name).not_ # *** SeleneCollection conditions *** -def size(number: int) -> Condition[Collection]: +def size(number: int) -> Condition[[Collection], None]: return _match.collection_has_size(number).not_ -def size_less_than(number: int) -> Condition[Collection]: +def size_less_than(number: int) -> Condition[[Collection], None]: return _match.collection_has_size_less_than(number).not_ -def size_less_than_or_equal(number: int) -> Condition[Collection]: +def size_less_than_or_equal(number: int) -> Condition[[Collection], None]: return _match.collection_has_size_less_than_or_equal(number).not_ -def size_greater_than(number: int) -> Condition[Collection]: +def size_greater_than(number: int) -> Condition[[Collection], None]: return _match.collection_has_size_greater_than(number).not_ -def size_at_least(number: int) -> Condition[Collection]: +def size_at_least(number: int) -> Condition[[Collection], None]: warnings.warn( 'might be deprecated; use have.size_greater_than_or_equal instead', PendingDeprecationWarning, @@ -199,56 +199,56 @@ def size_at_least(number: int) -> Condition[Collection]: return _match.collection_has_size_greater_than_or_equal(number).not_ -def size_greater_than_or_equal(number: int) -> Condition[Collection]: +def size_greater_than_or_equal(number: int) -> Condition[[Collection], None]: return _match.collection_has_size_greater_than_or_equal(number).not_ # todo: consider accepting ints -def texts(*partial_values: str) -> Condition[Collection]: +def texts(*partial_values: str) -> Condition[[Collection], None]: return _match.collection_has_texts(*partial_values).not_ -def exact_texts(*values: str) -> Condition[Collection]: +def exact_texts(*values: str) -> Condition[[Collection], None]: return _match.collection_has_exact_texts(*values).not_ -def url(exact_value: str) -> Condition[Browser]: +def url(exact_value: str) -> Condition[[Browser], None]: return _match.browser_has_url(exact_value).not_ -def url_containing(partial_value: str) -> Condition[Browser]: +def url_containing(partial_value: str) -> Condition[[Browser], None]: return _match.browser_has_url_containing(partial_value).not_ -def title(exact_value: str) -> Condition[Browser]: +def title(exact_value: str) -> Condition[[Browser], None]: return _match.browser_has_title(exact_value).not_ -def title_containing(partial_value: str) -> Condition[Browser]: +def title_containing(partial_value: str) -> Condition[[Browser], None]: return _match.browser_has_title_containing(partial_value).not_ -def tabs_number(value: int) -> Condition[Browser]: +def tabs_number(value: int) -> Condition[[Browser], None]: return _match.browser_has_tabs_number(value).not_ -def tabs_number_less_than(value: int) -> Condition[Browser]: +def tabs_number_less_than(value: int) -> Condition[[Browser], None]: return _match.browser_has_tabs_number_less_than(value).not_ -def tabs_number_less_than_or_equal(value: int) -> Condition[Browser]: +def tabs_number_less_than_or_equal(value: int) -> Condition[[Browser], None]: return _match.browser_has_tabs_number_less_than_or_equal(value).not_ -def tabs_number_greater_than(value: int) -> Condition[Browser]: +def tabs_number_greater_than(value: int) -> Condition[[Browser], None]: return _match.browser_has_tabs_number_greater_than(value).not_ -def tabs_number_greater_than_or_equal(value: int) -> Condition[Browser]: +def tabs_number_greater_than_or_equal(value: int) -> Condition[[Browser], None]: return _match.browser_has_tabs_number_greater_than_or_equal(value).not_ -def js_returned_true(script_to_return_bool: str) -> Condition[Browser]: +def js_returned_true(script_to_return_bool: str) -> Condition[[Browser], None]: warnings.warn( 'might be deprecated; use have.js_returned(True, ...) instead', PendingDeprecationWarning, @@ -256,5 +256,5 @@ def js_returned_true(script_to_return_bool: str) -> Condition[Browser]: return _match.browser_has_js_returned(True, script_to_return_bool).not_ -def js_returned(expected: Any, script: str, *args) -> Condition[Browser]: +def js_returned(expected: Any, script: str, *args) -> Condition[[Browser], None]: return _match.browser_has_js_returned(expected, script, *args).not_