Search code examples
pythonseleniumxpathiframeelement

Python with selenium: unable to locate element which really exists


while len(driver.find_elements(By.XPATH,"//*[@title='Next page']"))!=0:

The element is not found (and the while loop skept), I tried adding a timer

ui.WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH,"//*[@title='Next Page']")))

Still impossible to make selenium recognize the element. I don't think I saw anything that looked like an iframe on the source (I might have missed it).


Solution

  • Instead of presence_of_element_located() you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategy:

    ui.WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//*[@title='Next Page']"))).click()