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. I have tried the following code
def _kernel_is_idle(self):
return EC.visibility_of_element_located((By.XPATH, '//*[@id="kernel_indicator_icon" and @title="Kernel Idle"]'))
with the idea of checking an element (callable as a method within a class). There are two things that do not make any sense:
According to the documentation (I had to look up the source code!), this method should return either
TrueorFalse. However, it returns the following:<selenium.webdriver.support.expected_conditions.visibility_of_element_located object at 0x110321b90>How can this function work without a
webdriver? Usually you always have a call likedriver.do_something()
but where is the referece to the webdriver for an 'expected condition'?
Falsein case an element is not there? Likedriver.find_elements(By.XPATH, '//button')? Or do I have to dotry/except?visibility_of_element_locatedintend to check whether element is visible. Tha same you can try to do withdriver.find_element(By.XPATH, '//button').is_displayed(). If you want to check presence of element you can trybool(driver.find_elements(By.XPATH, '//button'))