The following code is not working. The selenium web driver just continues through without waiting even though neither of the elements are visible on the page. Therefore the assertion fails.
element = WebDriverWait(self.driver, 30).until(
lambda x: (EC.visibility_of_element_located((By.ID, "export_errors_button"))) or
(EC.visibility_of_element_located((By.ID, "finish_button")))
)
assert "finish_button" in element.get_attribute('id').split()
CodePudding user response:
I ended up writing a custom wait condition.
def one_of_these_elements_is_visible(element1, element2):
def wait_for_condition(driver):
attribute = driver.find_element(By.ID, element1).is_displayed()
if attribute:
return True
else:
return driver.find_element(By.ID, element2).is_displayed()
return wait_for_condition
element = WebDriverWait(self.driver, 20).until(one_of_these_elements_is_visible("finish_button",
"export_errors_button"))