Skip to content

Commit

Permalink
EC.invisibility_of_element_located should return the element. Fixes I…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeis committed Mar 3, 2015
1 parent 64efd11 commit e7620c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions py/selenium/webdriver/support/expected_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def __init__(self, element):
def __call__(self, ignored):
return _element_if_visible(self.element)

def _element_if_visible(element):
return element if element.is_displayed() else False
def _element_if_visible(element, visibility=True):
return element if element.is_displayed() == visibility else False

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

def __call__(self, driver):
try:
return not _find_element(driver, self.locator).is_displayed()
return _element_if_visible(_find_element(driver, self.locator), False)
except (NoSuchElementException, StaleElementReferenceException):
# In the case of NoSuchElement, returns true because the element is
# not present in DOM. The try block checks if the element is present
Expand Down
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/common/webdriverwait_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ def testExpectedConditionInvisiblityOfElementLocated(self):
except TimeoutException as e:
pass
self.driver.execute_script("delayedShowHide(200, false)")
WebDriverWait(self.driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
self.assertFalse(self.driver.find_element_by_id('clickToHide').is_displayed())
element = WebDriverWait(self.driver, 0.7).until(EC.invisibility_of_element_located((By.ID, 'clickToHide')))
self.assertFalse(element.is_displayed())


def testExpectedConditionElementToBeClickable(self):
Expand Down

0 comments on commit e7620c5

Please sign in to comment.