Skip to content

Commit 1f79785

Browse files
committed
add explicit condition of waiting for two elements to de-flake python phantomjs test
1 parent 1fe9a49 commit 1f79785

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ def testShouldWaitUntilAtLeastOneVisibleElementsIsFoundWhenSearchingForMany(self
6969
add_visible.click()
7070
add_hidden.click()
7171

72-
elements = WebDriverWait(driver, 2).until(EC.visibility_of_any_elements_located((By.CLASS_NAME, "redbox")))
72+
class wait_for_two_elements(object):
73+
def __init__(self, locator):
74+
self.locator = locator
75+
def __call__(self, driver):
76+
elements = [element for element in EC._find_elements(driver, self.locator) if EC._element_if_visible(element)]
77+
return elements if len(elements) == 2 else False
78+
79+
elements = WebDriverWait(driver, 2).until(wait_for_two_elements((By.CLASS_NAME, "redbox")))
7380
assert len(elements) == 2
7481

7582
def testShouldFailToFindVisibleElementsWhenExplicitWaiting(self, driver, pages):

0 commit comments

Comments
 (0)