diff --git a/splinter/driver/webdriver/__init__.py b/splinter/driver/webdriver/__init__.py index ff4b53557..a4bf95db6 100644 --- a/splinter/driver/webdriver/__init__.py +++ b/splinter/driver/webdriver/__init__.py @@ -869,7 +869,10 @@ def is_visible(self, wait_time=None): def search() -> bool: # Element is refreshed to account for changes to the page. - self._refresh_element(wait_time=0) + try: + self._refresh_element(wait_time=0) + except ElementDoesNotExist: + return False try: result = self.visible @@ -890,12 +893,18 @@ def is_not_visible(self, wait_time=None): def search() -> bool: # Element is refreshed to account for changes to the page. - self._refresh_element(wait_time=0) + try: + self._refresh_element(wait_time=0) + + # If an element is not found at all, we assume it's not visible. + except ElementDoesNotExist: + return True try: result = self.visible # StaleElementReferenceException occurs if element is found - # but changes before visible is checked + # but changes before visible is checked. Retry the check + # because we don't know if it's truly not visible. except StaleElementReferenceException: return False diff --git a/tests/static/index.html b/tests/static/index.html index 74666b164..a8265e73e 100644 --- a/tests/static/index.html +++ b/tests/static/index.html @@ -85,6 +85,11 @@ $('.over-label').remove(); $('.over-input').remove(); }); + + setTimeout(function() { + $('#removed_after_5_seconds').remove(); + }, 5000 ); + }); @@ -220,5 +225,7 @@