I have trouble understanding how to use an \'expected conditions\' to check for the presence of an element. Given this documentation it is not clear at all how to use this.
Seems you were almost there.
The Documentation clearly says the following:
class selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator)
Which is defined as :
An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. locator - used to find the element
returns the WebElement once it is located and visible
Hence, when you mention:
return EC.visibility_of_element_located((By.XPATH, '//*[@id="kernel_indicator_icon" and @title="Kernel Idle"]'))
The found out WebElement
is being returned as follows :
Even the Source Code says the same as :
try:
return _element_if_visible(_find_element(driver, self.locator))
When the search is unsuccessfull :
except StaleElementReferenceException:
return False