Skip to content

Commit

Permalink
Added wait for element to be in viewport for element.
Browse files Browse the repository at this point in the history
  • Loading branch information
VicGrygorchyk committed Nov 6, 2019
1 parent 47badf5 commit 4c581e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions se_wrapper/element/element_waits.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,16 @@ def not_present_in_dom(self, timeout: TimeoutType):
if timeout:
timeout_ = timeout
return self._webdriver.wait_for.no_element_in_dom(self._web_element, timeout_)

def to_be_on_the_screen(self, timeout: TimeoutType):
"""True for an element is present on the screen (inside the viewport).
Checks if element's coordinates match viewport height and width.
Different from `to_be_visible` as `to_be_visible` checks element has size > 1px
and display is not `:none`.
:param timeout: equal to the self.timeout if other not passed.
"""
timeout_ = self._timeout
if timeout:
timeout_ = timeout
return self._webdriver.wait_for.element_to_be_in_viewport(self._web_element, timeout_)
14 changes: 14 additions & 0 deletions se_wrapper/element/expectations.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,17 @@ def not_present_in_dom(self, timeout: TimeoutType):
return self._webdriver.wait_for.no_element_in_dom(self._web_element, timeout_)
except TimeoutException:
return False

def to_be_on_the_screen(self, timeout: TimeoutType):
"""True for an element is present on the screen (inside the viewport).
False if element's coordinates don't match viewport height and width.
:param timeout: equal to the self.timeout if other not passed.
"""
timeout_ = self._timeout
if timeout:
timeout_ = timeout
try:
return self._webdriver.wait_for.element_to_be_in_viewport(self._web_element, timeout_)
except TimeoutException:
return False

0 comments on commit 4c581e2

Please sign in to comment.