WebDriverWait not working as expected
Solution 1:
Once you wait for the element and moving forward as you are trying to invoke click()
method instead of using presence_of_element_located()
method you need to use element_to_be_clickable()
as follows :
try:
myElem = WebDriverWait(self.browser, delay).until(EC.element_to_be_clickable((By.XPATH , xpath)))
Update
As per your counter question in the comments here are the details of the three methods :
presence_of_element_located
presence_of_element_located(locator) is defined as follows :
class selenium.webdriver.support.expected_conditions.presence_of_element_located(locator)
Parameter : locator - used to find the element returns the WebElement once it is located
Description : An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible or interactable (i.e. clickable).
visibility_of_element_located
visibility_of_element_located(locator) is defined as follows :
class selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator)
Parameter : locator - used to find the element returns the WebElement once it is located and visible
Description : 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.
element_to_be_clickable
element_to_be_clickable(locator) is defined as follows :
class selenium.webdriver.support.expected_conditions.element_to_be_clickable(locator)
Parameter : locator - used to find the element returns the WebElement once it is visible, enabled and interactable (i.e. clickable).
Description : An Expectation for checking an element is visible, enabled and interactable such that you can click it.