Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/web/javascriptPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ <h1>Type Stuff</h1>
Focusable. Will hide when focus is lost.
</div>

<div style="margin-top: 10px;">
<div id="clickToShowParent" style="margin-top: 10px;">
Click actions delayed by 3000ms:
<div id="clickToShow" onclick="delayedShowHide(3000, true);"
style="float: left;width: 100px;height:100px;border: 1px solid black;">
Expand Down
21 changes: 21 additions & 0 deletions py/selenium/webdriver/support/expected_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,27 @@ def _predicate(_):

return _predicate

def elements_not_overlapping(element1: WebElement, element2:WebElement) -> Callable[[Any], bool]:
"""An Expectation for checking that two elements do not overlap on the DOM

elements are WebElement objects
"""

def _predicate(_):
if staleness_of(element1):
return True
if staleness_of(element2):
return True

rect1 = element1.rect
rect2 = element2.rect
return (rect1['x'] + rect1['width'] < rect2['x'] or
rect2['x'] + rect2['width'] < rect1['x'] or
rect1['y'] + rect1['height'] < rect2['y'] or
rect2['y'] + rect2['height'] < rect1['y'])

return _predicate


def element_to_be_selected(element: WebElement) -> Callable[[Any], bool]:
"""An expectation for checking the selection is selected.
Expand Down
17 changes: 17 additions & 0 deletions py/test/selenium/webdriver/common/webdriverwait_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,23 @@ def test_expected_condition_element_to_be_clickable(driver, pages):
WebDriverWait(driver, 4.5).until(EC.invisibility_of_element_located((By.ID, "clickToHide")))
assert element.is_displayed() is False

def test_expected_condition_elements_not_overlapping(driver, pages):
pages.load("javascriptPage.html")
element1 = driver.find_element(By.ID, 'keyUp')
element2 = driver.find_element(By.ID, 'keyDown')
WebDriverWait(driver, 1).until(EC.elements_not_overlapping(element1,element2))
clickToShow = driver.find_element(By.ID, 'clickToShow')
clickToShow.click()
WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.ID, "clickToHide")))
element1 = driver.find_element(By.ID, 'clickToHide')
element2 = driver.find_element(By.ID, 'clickToShowParent')
with pytest.raises(TimeoutException):
WebDriverWait(driver, 1).until(EC.elements_not_overlapping(element1,element2))
element1.click()
WebDriverWait(driver, 5).until(EC.elements_not_overlapping(element1,element2))
assert element1.is_displayed() is False



def test_expected_condition_staleness_of(driver, pages):
pages.load("dynamicallyModifiedPage.html")
Expand Down