I want to wait for the element to disappear on Selenium, but at the same time I must ensure that all the elements are gone. Right now, it is something like this:
element = WebDriverWait(driver, 30).until(
expected_conditions.element_to_be_clickable((By.XPATH, xpath))
)
is_clickable = WebDriverWait(driver, 30).until(
expected_conditions.invisibility_of_element_located((By.XPATH, layovers[0]))
)
is_clickable_2 = WebDriverWait(driver, 30).until(
expected_conditions.invisibility_of_element_located((By.XPATH, layovers[1]))
)
if is_clickable and is_clickable_2:
element.click()
And there are more than two elements on the layovers
list, which store xpaths as str
.
In this case, can I make all of them into a single function that checks the invisibility of the elements, instead of repeating them? (I mean, make the WebDriverWait takes only one call, and not define another wrapper function.)