Skip to content

Commit e7620c5

Browse files
committed
EC.invisibility_of_element_located should return the element. Fixes Issue #8493
1 parent 64efd11 commit e7620c5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

py/selenium/webdriver/support/expected_conditions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def __init__(self, element):
8686
def __call__(self, ignored):
8787
return _element_if_visible(self.element)
8888

89-
def _element_if_visible(element):
90-
return element if element.is_displayed() else False
89+
def _element_if_visible(element, visibility=True):
90+
return element if element.is_displayed() == visibility else False
9191

9292
class presence_of_all_elements_located(object):
9393
""" An expectation for checking that there is at least one element present
@@ -167,7 +167,7 @@ def __init__(self, locator):
167167

168168
def __call__(self, driver):
169169
try:
170-
return not _find_element(driver, self.locator).is_displayed()
170+
return _element_if_visible(_find_element(driver, self.locator), False)
171171
except (NoSuchElementException, StaleElementReferenceException):
172172
# In the case of NoSuchElement, returns true because the element is
173173
# not present in DOM. The try block checks if the element is present

py/test/selenium/webdriver/common/webdriverwait_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def testExpectedConditionInvisiblityOfElementLocated(self):
225225
except TimeoutException as e:
226226
pass
227227
self.driver.execute_script("delayedShowHide(200, false)")
228-
WebDriverWait(self.driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
229-
self.assertFalse(self.driver.find_element_by_id('clickToHide').is_displayed())
228+
element = WebDriverWait(self.driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
229+
self.assertFalse(element.is_displayed())
230230

231231

232232
def testExpectedConditionElementToBeClickable(self):

0 commit comments

Comments
 (0)